国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android TabWidget底部顯示效果

2019-12-12 03:27:32
字體:
來源:轉載
供稿:網友

TabHost控件默認使用LinearLayout包裹TabWidget和FrameLayout,布局文件如下:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"  android:id="@android:id/tabhost"  android:layout_width="match_parent"  android:layout_height="match_parent" >   <LinearLayout   android:layout_width="match_parent"   android:layout_height="match_parent"   android:orientation="vertical" >    <TabWidget    android:id="@android:id/tabs"    android:layout_width="match_parent"    android:layout_height="wrap_content" >   </TabWidget>    <FrameLayout    android:id="@android:id/tabcontent"    android:layout_width="match_parent"    android:layout_height="match_parent" >   </FrameLayout>  </LinearLayout> </TabHost> 

這樣TabWidget顯示在頂部,如果想把TabWidget放到底部有三種方式。

方式一:將TabHost中默認的LinearLayout換成RelativeLayout,并給TabWidget添加Android:layout_alignParentBottom="true"

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"  android:id="@+id/tabhost"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:layout_alignParentLeft="true"  android:layout_alignParentTop="true" >  <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>      <FrameLayout    android:id="@android:id/tabcontent"    android:layout_width="match_parent"    android:layout_height="match_parent" >   </FrameLayout>  </RelativeLayout> </TabHost> 

方式二:

1、將LinearLayout中TabWidget和FrameLayout交換位置
2、設置FrameLayout的屬性:android:layout_weight="1" android:layout_height="0dp"

<TabHost xmlns:android="<a target=_blank  rel="external nofollow" >http://schemas.android.com/apk/res/android</a>"  android:id="@+id/tabhost"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:layout_alignParentLeft="true"  android:layout_alignParentTop="true" ></p><p> <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="0dp"    android:layout_weight="1" >   </FrameLayout>      <TabWidget    android:id="@android:id/tabs"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:layout_alignParentBottom="true">   </TabWidget>  </LinearLayout> </TabHost>

方式三:

1、將TabWidget移動到LinearLayout標簽以下             

2、在FrameLayout中加入屬性:android:layout_gravity="top"             

3、在TabWidget中加入屬性:android:layout_gravity="bottom"

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"  android:id="@+id/tabhost"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:layout_alignParentLeft="true"  android:layout_alignParentTop="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" >   </FrameLayout>  </LinearLayout>  <TabWidget   android:id="@android:id/tabs"   android:layout_width="match_parent"   android:layout_height="wrap_content"   android:layout_gravity="bottom">  </TabWidget> </TabHost> 

以上三種方式在Android4.2下測試通過。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 景洪市| 河北区| 莱芜市| 巫山县| 泰州市| 长顺县| 抚远县| 同德县| 韩城市| 蒲江县| 惠州市| 莱芜市| 冷水江市| 大新县| 金昌市| 霍邱县| 海宁市| 大城县| 宁陕县| 霍山县| 鹰潭市| 耒阳市| 城固县| 都兰县| 尉犁县| 迭部县| 内乡县| 巴塘县| 蒲江县| 灌云县| 莲花县| 汽车| 青铜峡市| 高碑店市| 治多县| 肥西县| 三明市| 盐城市| 长春市| 综艺| 吴川市|