The tabhost component that comes with Android is located at the top of the page. If you want it to be located at the bottom of the page, two methods are provided here.
Method 1
1. tabcontent and tabs interchange locations
2. Set the attributes of tabcontent: android: layout_weight = "1"
Example
<? Xml version = "1.0" encoding = "UTF-8"?> <RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent"> <TabHost android: id = "@ android: id/tabhost" android: layout_width = "match_parent" android: layout_height = "match_parent" android: layout_alignParentLeft = "true" android: Layout = "true"> <LinearLayout android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical"> <FrameLayout android: id = "@ android: id/tabcontent" android: layout_width = "match_parent" android: layout_height = "match_parent" android: layout_weight = "1"> the middle part is omitted </FrameLayout> <TabWidget android: id = "@ android: id/tabs" android: layout_width = "match_parent" android: layout_height = "wrap_content"> </TabWidget> </LinearLayout> </TabHost> </RelativeLayout>
Method 2
1. tabcontent and tabs interchange locations
2. put tabs in a relativeLayout, and add the following attributes: android: layout_alignParentBottom = "true"
Example
<? Xml version = "1.0" encoding = "UTF-8"?> <RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent"> <TabHost android: id = "@ android: id/tabhost" android: layout_width = "match_parent" android: layout_height = "match_parent" android: layout_alignParentLeft = "true" android: Rule = "true"> <FrameLayout android: id = "@ android: id/tabcontent "android: layout_width =" match_parent "android: layout_height =" match_parent "> omitted middle part </FrameLayout> <RelativeLayout android: layout_width =" match_parent "android: layout_height = "match_parent"> <TabWidget android: id = "@ android: id/tabs" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_alignParentBottom = "true"> </TabWidget> </RelativeLayout> </TabHost> </RelativeLayout>
Method 3 1. Change the positions of tabcontent and tabs (tabs is moved below the LinearLayout label). 2. Add the attribute to tabcontent: android: layout_gravity = "top"
3. Add attributes to tabs: android: layout_gravity = "bottom"
Example
<? 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 = "match_parent" android: layout_height = "match_parent" android: feature = "true" android: layout_alignParentLeft = "true"> <LinearLayout android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical"> <FrameLayout android: id = "@ android: id/tabcontent" android: layout_width = "match_parent" android: layout_height = "match_parent" android: layout_gravity = "top"> the middle part is omitted </FrameLayout> </LinearLayout> <TabWidgetandroid: id = "@ android: id/tabs" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_gravity = "bottom"> </TabWidget> </TabHost> </RelativeLayout>