Reputation: 3580
as you can see, I've a bottom bar (its not using TabHost or anything, partially because obviously its depreciated but also partially because this is only on two activities in the app so I don't need to do a tab host for just two pages). Anyway there is content 'under' that tab bar. Android won't scroll any further because as it sees it that content is viewable, yet it isn't really.
My question is whats the best way to get that content up above the tab bar.
Some ideas I had:
You might be interested in my xml structure:
<RelativeLayout>
<ScrollView>
<LinearLayout>
<RelativeLayout>
<LinearLayout>
</LinearLayout>
<LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
<LinearLayout>
TAB BAR
</LinearLayout>
</RelativeLayout>
Upvotes: 0
Views: 714
Reputation: 5266
Give the tab bar a view id in the xml, then set the view that appears behind it to be "layout_above" the tab bar view, and make sure they are both inside the same RelativeLayout.
So, for example:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<LinearLayout
android:id="@+id/top_area"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/bottom_bar"
android:orientation="vertical" />
</RelativeLayout>
This will cause the content behind to be pushed above, and you can then put that top_area layout into a scrollview, which will then be scrollable and always sit above the bottom bar.
For example:
<ScrollView
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/bottom_bar" >
<LinearLayout
android:id="@+id/top_area"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" />
</ScrollView>
This will place the scrollview above the bottom bar, with the top_area layout contained within it and scrollable
Upvotes: 0
Reputation: 152817
RelativeLayout
happily lays all its children on top of each other unless specified otherwise. Some ideas to fix it:
Change the top RelativeLayout
to a LinearLayout
with orientation="vertical"
and ScrollView
layout_weight
specified to a nonzero value so that the tab bar is always in bottom and the scroll view takes up all remaining vertical space.
Keep the RelativeLayout
but layout the tab bar first with layout_alignParentBottom="true"
and then your scroll view with layout_above="@id/your_tabbar_id"
.
Upvotes: 0
Reputation: 46425
Alternatively to @Antarix Tandon's answer, you could change your root relative layout to be a vertical linear layout.
Upvotes: 0
Reputation: 685
if your TAB BAR has fixed height than you can set ScrollView
margin bottom attribute. This will always show your ScrollView
data above the TAB BAR
Upvotes: 3