开发者

How do you set tab view to scroll?

I have managed to set up a tabbed view for my app (woo!)

and have the following xml for the UI

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dp">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
    />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    />
</LinearLayout>

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              开发者_开发技巧android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <Spinner android:id="@+id/areaSpinner"
             android:layout_width="fill_parent"
             android:layout_height="@dimen/one_row"
     />
     <Spinner android:id="@+id/cragSpinner"
              android:layout_width="fill_parent"
              android:layout_height="@dimen/one_row"
     />
     <Spinner android:id="@+id/routeSpinner"
              android:layout_width="fill_parent"
              android:layout_height="@dimen/one_row"
     />
     <DatePicker android:id="@+id/dateClimbed"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
     />
     <Spinner android:id="@+id/styleSpinner"
              android:layout_width="fill_parent"
              android:layout_height="@dimen/one_row"
     />
     <Spinner android:id="@+id/detailsSpinner"
              android:layout_width="fill_parent"
              android:layout_height="@dimen/one_row"
     />
     <TextView android:id="@+id/climbNotes"
             android:layout_width="fill_parent"
             android:layout_height="@dimen/three_row"
   />
</LinearLayout>

yet am seemingly unable to scroll down to see the rest of the form (cuts off at one of the spinners, why is this? and how do i fix it?


I had the same problem!

What I did was insert a ScrollView into the first XML file just "inside" the TabHost tags, like so:

<TabHost>
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout>

... the rest of your stuff

</LinearLayout>
</ScrollView>
</TabHost>

Hope this helps!


Do you have the contents of the tab in a ScrollView?

Edit: After I fixed your XML formatting I could see your 2nd XML file. You need to wrap everything in that 2nd layout in a ScrollView.

2nd Edit: Try editing your 2nd XML file so that it follows this pattern:

<ScrollView>
   <LinearLayout>
     ... all your other stuff
   </LinearLayout>
</ScrollView>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜