Android: ScrollView + ViewFlipper + Bottom Bar
I am trying to build an activity structured as follows:
- TopBar
- ScrollView
- > ViewFlipper
- Bottom Bar
What I have done is:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout style="@style/TitleBar">
TOP BAR
</LinearLayout>
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ViewFlipper andr开发者_开发技巧oid:id="@+id/details"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
VIEW FLIPPER
</ViewFlipper>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="@android:drawable/bottom_bar"
android:gravity="center_vertical">
BOTTOM BAR
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
This, of course, is not working.
In fact, it seems the bottom bar is hidden under the viewflipper
.
How can I fix this?
I'd try to achieve this in the following way:
<LinearLayout style="@style/TitleBar">
TOP BAR
</LinearLayout>
<ScrollView android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:fillViewport="true" >
<ViewFlipper android:id="@+id/details"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
VIEW FLIPPER
</ViewFlipper>
</ScrollView>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="@android:drawable/bottom_bar"
android:gravity="center_vertical">
BOTTOM BAR
</LinearLayout>
You can use weigths
for this.
Try this:
<ViewFlipper android:id="@+id/details"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
VIEW FLIPPER
</ViewFlipper>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:padding="10dp"
android:background="@android:drawable/bottom_bar"
android:gravity="center_vertical">
BOTTOM BAR
</LinearLayout>
That will give equal space to the ViewFlipper
and the second LinearLayout
.
精彩评论