Android: Adding a View underneath a TabActivity
So I have a tab activity with 2 tabs. Underneath these I would like to have a second view. At the moment I can put the view at the end but it still overlaps with whatever is at the end of the currently visible tab. Does anyone have an idea of how to get the second view 开发者_如何学JAVAbeneath the tabs rather than overlap the end of their content?
So for example if the view is just a textview, my layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/linearLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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>
</TabHost>
<RelativeLayout android:id="@+id/InnerRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView android:id="@+id/EndView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="At the end of the screen"/>
</RelativeLayout>
</RelativeLayout>
Use android:below="@id/tabhost"
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost ...>
...
</TabHost>
<RelativeLayout android:id="@+id/InnerRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:below="@id/tabhost"><!-- LOOK HERE -->
<TextView android:id="@+id/EndView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="At the end of the screen"/>
</RelativeLayout>
</RelativeLayout>
精彩评论