Android TabLayout tabPadding底部和顶部不起作用?

时间:2016-11-23 13:52:28

标签: android android-imageview android-tablayout

我想要TabLayout标签而不填充。而tabPaddingStart,tabPaddingEnd正在工作。但是tabPaddingBottom和tabPaddingTop无效。 我将它们的值改为-1和0,但我的项目没有变化。

我想问的其他事情是我的标签处于可怕状态后的屏幕旋转。 TextView没有完全显示。和ImageView .....

这是我的活动

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:design="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="10">

<android.support.v4.view.ViewPager
    android:id="@+id/view_pager_main_content"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="9">
</android.support.v4.view.ViewPager>

<android.support.design.widget.TabLayout
    android:id="@+id/tab_layout"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:visibility="visible"
    android:layout_weight="1"
    design:tabBackground="@drawable/tab_color_selector"
    design:tabIndicatorColor="@color/colorPrimary"
    design:tabMaxWidth="0dp"

    design:tabPaddingStart="0dp"  // working
    design:tabPaddingEnd="0dp"    // working
    design:tabPaddingBottom="0dp" 
    design:tabPaddingTop="0dp"

    design:tabContentStart="0dp"
    design:tabGravity="fill"
    design:tabMode="fixed"
    >

</android.support.design.widget.TabLayout>

</LinearLayout>
                 //Tab Layout selector
     <?xml version="1.0" encoding="utf-8"?>
   <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/colorPrimaryTransparent"   
     android:state_selected="true"></item>
    <item android:drawable="@color/white" 
     android:state_selected="false"></item>
     </selector>

“我的tabLayout自定义标签样式”

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4">

<ImageView
    android:id="@+id/icon_tab"
    android:layout_gravity="center_horizontal"
    android:scaleType="fitXY"
    android:background="@color/colorPrimaryDark"
    android:paddingLeft="4dp"
    android:paddingRight="4dp"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="3"/>
<TextView
    android:id="@+id/text_tab"
    android:textStyle="bold"
    android:textAlignment="center"
    android:textColor="#000000"
    android:background="@color/colorAccent"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:textAppearance="?android:attr/layout"
    />
    </LinearLayout>

0 个答案:

没有答案