Android 如何在fragmenttabhost中对齐屏幕底部的选项卡
我想对齐屏幕底部的选项卡。我尝试使用alignParentBottom“true”使用相对布局进行对齐,但未成功。有人能指引我吗Android 如何在fragmenttabhost中对齐屏幕底部的选项卡,android,fragment-tab-host,Android,Fragment Tab Host,我想对齐屏幕底部的选项卡。我尝试使用alignParentBottom“true”使用相对布局进行对齐,但未成功。有人能指引我吗 <android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tabhost" android:layout_width="match_parent" andr
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+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="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<FrameLayout
android:id="@+id/tabFrameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
您只需将这两行添加到选项卡小部件中即可
<TabWidget
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:layout_weight="0"
android:orientation="horizontal" />
在底部定位选项卡是一种不好的做法,但如果需要,可以按权重=0隐藏android小部件,并使用您自己的“realcontent”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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<FrameLayout
android:id="@+android:id/realtabcontent"
android:background="@drawable/bg_main_app_gradient"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<TabWidget
android:id="@android:id/tabs"
android:background="#EAE7E1"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
</LinearLayout>
</TabHost>
选项卡应始终位于AndroidI发布的我的代码的顶部,您只需使用它…我希望它将帮助您。。。