【问题标题】:To want Tab layout set in bottom in android想要在 android 的底部设置 Tab 布局
【发布时间】:2012-02-15 18:45:42
【问题描述】:

如何在底部设置选项卡布局? 我试试这个属性

android:gravity="bottom"
android:layout_marginBottom="-3dp" 

但没有任何效果并给出错误。

【问题讨论】:

标签: android


【解决方案1】:
Place Tab Widget to below FrameLayout like this

<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
         android:id="@+id/tabHost"
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent">
    <LinearLayout android:orientation="vertical"
                  android:layout_width="fill_parent" 
                  android:layout_height="fill_parent">

         <FrameLayout android:id="@android:id/tabcontent"
                     android:layout_width="fill_parent" 
                     android:layout_height="0dip"
                     android:layout_weight="1"  >

       </FrameLayout>


        <TabWidget android:id="@android:id/tabs"
                   android:layout_height="wrap_content" 
                   android:layout_width="fill_parent"
                   android:layout_weight="0" />



    </LinearLayout>
</TabHost>

【讨论】:

    【解决方案2】:

    你有一个最好的 android 选项卡布局,可以在布局底部进行设置。只需使用此代码 -

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="0dip"
    android:layout_height="55dip"    
    android:layout_weight="1"
    android:orientation="vertical"
    
    android:background="@drawable/tab_indicator"
    android:padding="5dp">
    
    <ImageView android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:src="@drawable/icon"
    
    /> 
    
    <TextView android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" 
        android:layout_centerHorizontal="true"
        style="?android:attr/tabWidgetStyle"
    />    
    

    还有,请参阅answer。希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-30
      • 2016-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      相关资源
      最近更新 更多