I am creating the TabHost activity and taking a ListView in the TabHost. The ListView is bydefault scroll vertically wihtin TabHost.
Now i want to take ScrollView within the TabHost. Is it possible to do like that, because i have tried but it's not working.
Kindly help me out. please provide me any tutorial link related to this.
With Thanks
Vikash
you can use a scrollView within TabHost, But you need to take horizontal scrollView as main tag within that TabHost.
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
Related
I want a ListView to fill the space available to it while still leaving room for a small footer view at the bottom of the screen. I'm trying to use a RelativeLayout to accomplish this and attempted to use the solution discussed at Limit number of rows of listview . The problem I'm running into is I'm using nested Fragments, so my ListView is actually a FrameLayout in my xml then I load a ListFragment into that frame dynamically. Given the nested fragment stipulation, how can I get my FrameLayout to "stackFromBottom" as I would with a ListView? I just need to stop the list from pushing the other View off the bottom of the screen. Thanks for your time all.
Here is the solution I came up with:
<TextView
android:id="#+id/advertisement"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="Ads will appear here"
android:gravity="center"
android:layout_alignParentBottom="true"/>
<FrameLayout
android:id="#+id/news_frag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/carousel_menu"
android:layout_above="#id/advertisement"/>
The trick was to set both layout_above AND layout_below for the FrameLayout, I had only been setting one and that was apparently allowing the layout to push it off of the screen. Also worth noting is they had to be declared in reverse order of how they actually appear on the page, so that the FrameLayout could properly reference the other View.
I'm building an app which I'd like to add a ListView to an activity not a listActivity but the activity also contains other widget controls. Iv tried doing it but it doesn't look good at all. Here is the xml that created the ListView in my activity:
<ListView
android:id="#+id/experienceList"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="18dp"
android:layout_marginLeft="18dp" >
</ListView>
Unfortunately stackoverflow didn't allow me to post a image. But the ListView doesn't reveal all its contents. how can I make the ListView reveal all and just stretch it out, the root of the activity is a scrollView so it should probably work the way i want it.
Putting a scrollable (ListView) inside another one (ScrollView) will not work, for obvious reasons. Please refer to this question for more details, answered by Google's very own Romain Guy. Replace your ListView by a LinearLayout ...
I am trying to use Chris Banes' library Actionbar-PullToRefresh. It can be found here.
I am using Tabs + ViewPager + Fragments in my app.
The problem I'm facing is that my fragment has a GridView and I cannot figure out how to use this library to work with it.
I read through the sample code. He says that all you have to do is, wrap your refreshable view in a PullToRefreshLayout like this:
<uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ptr_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Your content, here we're using a ScrollView -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ScrollView>
</uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout>
This works great for stuff like ListView, ScrollView, GridView, etc. However, apparently this will not work for Fragments (Tabs & ViewPagers). Now, in the sample code he has wrapped the refreshable fragment with a ScrollView INSTEAD of a PullToRefreshLayout.
I cannot do this because my Fragment 1 (under tab 1) has a GridView. Now I cannot add a GridView to a ScrollView because that just wouldn't make sense.
For example, if I put my GridView inside the ScrollView as shown below, it just doesn't make sense:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ptr_scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbarStyle="outsideInset" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFF000" >
<!-- MY GRID VIEW -->
<GridView
...
/>
</RelativeLayout>
</ScrollView>
The above code works. Sort of. (I need to disable scrolling of my GridView and use an ExpandableGridView to get it working properly... which seems like overkill & I'm not even sure if that would work).
If I replace the ScrollView wrapper with anything else like PullToRefreshLayout or any other layout, the refreshing doesn't work.
What to do? How to get my layout to work with this library without wrapping a ScrollView around it?
I hope I was clear enough. Please let me know if you need any more info. I tried to explain it the best I could.
Thanks!
I had a similar issue trying to get it to work with a ListView that I had in one of my tabs.
I solved my issue by using the PullToRefreshAttacher instead of using the layout.
In your Activity that is controlling the ViewPager for the fragments, initialize a PullToRefreshAttacher in onCreate or an init method.
mPullToRefreshAttacher = PullToRefreshAttacher.get(this);
Next make a public method that allows access to the attacher that you just initialized.
public PullToRefreshAttacher getPullToRefreshAttacher() {
return mPullToRefreshAttacher;
}
Then in the fragment you want the refresh functionality.
mPullToRefreshAttacher = ((MainTabActivity) getActivity())
.getPullToRefreshAttacher();
mPullToRefreshAttacher.addRefreshableView(activeListView, this);
Except in your case activeListView would be the reference to your GridView instead of a ListView.
Then make sure your fragment implements OnRefreshListener so you can handle the Refresh.
I have not actually tested this with a GridView so let me know if it works.
Good Luck!
So I have a horizontalscrollview and I want to try add a snapping effect, that basically centers an element.
I have done it all in XML basically so far.
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scrollbars="none" >
And then I have a LinearLayout inside of it.
So how do I go about making the elements inside of the LinearLayout snap? Also, is there a way to make the layout start on the middle element? So when you see the scroller, you can scroll left or right from the start.
Would appreciate any help with this! Thanks guys!
Why don't you use viewpager (http://developer.android.com/reference/android/support/v4/view/ViewPager.html)?
but if you insist to use horizontal scroll view there are some tutorial out there you can follow like this
-http://www.dev-smart.com/archives/34
-http://blog.velir.com/index.php/2010/11/17/android-snapping-horizontal-scroll/
-http://androidprogrammingmadeeasy.blogspot.com/2011/08/creating-custom-horizontal-scroll-view.html
Alright, so I followed the Tab Widget tutorial to create some tabs for my application. In one of the tabs, I have a TextView with a lot of text that I'm debugging with. But, with all of the text, all of the info doesn't show up on the screen. I figured that I could scroll down to see the rest, but I cannot scroll. Any idea on how to make it so that I can scroll down my FrameLayout so I can see the rest of my text?
You can surround the view that you want to be scrollable with a ScrollView, as below:
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
// the views here that you want to make scrollable
</ScrollView>