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

Kha*_*uun 5 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>
Run Code Online (Sandbox Code Playgroud)

“我的 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>
Run Code Online (Sandbox Code Playgroud)