I am trying to make an interface in which there are three tabs inside a tabhost and which will have their own individual scroll views.
The content placeholder of individual tabs has to be scrollable but from below the tab button itself (so that user can change from tab#1 to tab#2 without scrolling all the way up by just clicking in the tab's button.)
This is kind of a layout in which scroll views are inside the content placeholder of the tab(s) and not a tab inside a scroll view.
So far I have come up with this:
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".Ques2" >
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:gravity="bottom" />
<FrameLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tabview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollViewTab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true" >
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1_monthly_vOlslab_R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/monthly_vOlslab_R1"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/cb1R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1_monthly_vOlslab_R1"
android:text="@string/cb1R1" />
<CheckBox
android:id="@+id/cb2R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cb1R1"
android:text="@string/cb2R1" />
<CheckBox
android:id="@+id/cb3R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cb2R1"
android:text="@string/cb3R1" />
<CheckBox
android:id="@+id/cb4R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cb3R1"
android:text="@string/cb4R1" />
<CheckBox
android:id="@+id/cb5R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cb4R1"
android:text="@string/cb5R1" />
<CheckBox
android:id="@+id/cb6R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cb5R1"
android:text="@string/cb6R1" />
<CheckBox
android:id="@+id/cb7R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cb6R1"
android:text="@string/cb7R1" />
<CheckBox
android:id="@+id/cb8R1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cb7R1"
android:text="@string/cb8R1" />
<View
android:id="@+id/viewTab1Q1"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="@+id/cb8R1"
android:background="@android:color/darker_gray"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tabview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="tabview2" />
</LinearLayout>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tabview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="tabview3" />
</LinearLayout>
</FrameLayout>
</RelativeLayout>
</TabHost>
Thanks
Do not do this, TabHost
is old and horrible. Use Fragments
and a ViewPager
ViewPager.
There is a plethora of tutorials and examples of how to do this. The best being from @commonsguy Fragments with ViewPager