为选项卡式页面选项卡文本设置自定义字体大小

Cap*_*ere 2 xamarin.android xamarin.forms

我试图减少Tab文本大小的大小,因为它被删除了长文本.我尝试过以下解决方案,但它似乎没有用.

 <style name="MainTheme" parent="MainTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#1976D2</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#FF4081</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>

    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>

    <item name="android:actionBarTabTextStyle">@style/CustomTab</item>
    <item name="actionBarTabTextStyle">@style/CustomTab</item>
  </style>

  <style name="CustomTab"
         parent="@style/Widget.AppCompat.Light.ActionBar.TabText">
    <item name="android:textSize">5sp</item>
  </style>
Run Code Online (Sandbox Code Playgroud)

有人能帮助我吗?

Yur*_*i S 6

在styles.xml中

  <style name="MyTabLayout" parent="Base.Widget.Design.TabLayout">
    <item name="tabTextAppearance">@style/MyTabTextAppearance</item>
  </style>

  <style name="MyTabTextAppearance" parent="TextAppearance.AppCompat.Button">
    <item name="android:textSize">5sp</item>
  </style>
Run Code Online (Sandbox Code Playgroud)

在Tabbar.axml中

<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:tabIndicatorColor="@android:color/white"
    style="@style/MyTabLayout"
    app:tabGravity="fill"
    app:tabMode="fixed" />
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述