-
對於Android自帶的tabhost組件,是位於頁面頂端的,若想讓其位於頁面底端,在這裏提供兩種方法。
方法一1、tabcontent和tabs交換位置2、設置tabcontent的屬性:android:layout_weight="1"範例[html]<?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" ><TabHostandroid:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentLeft="true"android:layout_alignParentBottom="true" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1" >中間部分省略</FrameLayout><TabWidgetandroid:id="@android:id/tabs"android:layout_width="match_parent"android:layout_height="wrap_content" ></TabWidget></LinearLayout></TabHost></RelativeLayout>方法二1、tabcontent和tabs交換位置2、將tabs放到一個relativeLayout中,然後加上如下屬性:android:layout_alignParentBottom="true"範例[html]<?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" ><TabHostandroid:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentLeft="true"android:layout_alignParentBottom="true" ><FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="match_parent"android:layout_height="match_parent" >中間部分省略</FrameLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent" ><TabWidgetandroid:id="@android:id/tabs"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true" ></TabWidget></RelativeLayout></TabHost></RelativeLayout>方法三1、將tabcontent和tabs交換位置(tabs移動到LinearLayout標籤以下)2、在tabcontent中加入屬性:android:layout_gravity="top"3、在tabs中加入屬性:android:layout_gravity="bottom"範例[html] <?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" ><TabHostandroid:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentBottom="true"android:layout_alignParentLeft="true" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_gravity="top">中間部分省略</FrameLayout></LinearLayout><TabWidgetandroid:id="@android:id/tabs"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="bottom" ></TabWidget></TabHost></RelativeLayout>
-
設置tabhost位於底部的三種方法
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.