我正在尝试减小 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>
谁能帮帮我?
最佳答案
在 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>
在 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" />
关于xamarin.android - 为选项卡式页面选项卡文本设置自定义字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45643801/