Here is the structure of the layout of my application:
<LinearLayout>
<TabHost>
<LinearLayout>
<LinearLayout>
开发者_JAVA百科 <TabWidget />
<FrameLayout />
</LinearLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
The above layout works perfectly. I want to add a textview to show a text in the bottom of the screen. So for showing the text always in the bottom of the screen, I need to create a relative layout.
I have created a RelativeLayout and placed the textview inside the RelativeLayout like this :
<RelativeLayout>
<TextView />
</RelativeLayout>
How can I add this to the original view. I have tried several ways to add but nothing works! :(
My aim is to a show a text in the bottom of the screen. Is there any way to do this using any layout.
Add the RelativeLayout beneath the TabHost, make the parent LinearLayout also relative and make the child one android:layout_alignInParentBottom="true"
Taken from : ListView with Footer Item and adapted
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/bottom_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<!--Put whatever view item you want here -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/bottom_view"
>
<TabHost>
<LinearLayout>
<LinearLayout>
<TabWidget />
<FrameLayout />
</LinearLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
</RelativeLayout>
But I'm sure there's a nicer way to do it with the amount of nested layouts you have.
精彩评论