Android 选项卡标题小写
Android tab titles lowercase
也许没什么大不了的,但我无法让它工作。我有一个选项卡导航,我将 strings.xml 中的选项卡标题作为数组:
String[] tbTitles= resources.getStringArray(R.array.tabname);
for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
actionBar.addTab(
actionBar.newTab()
.setText(tbTitles[i])
.setTabListener(this));
}
}
选项卡名称被定义为小写(或者更准确地说是大写 - 示例)。它工作正常,但问题出在较旧的 API 上,其中每个选项卡标题都是大写的。
我在这个论坛上浏览了一些解决方案,但没有找到任何解决方案。
我试着把它放在我的 for 循环中:
tbTitles[i] = tbTitles[i].toLowerCase();
我也试过把它放到我的 tablayout 样式中 styles.xml:
<item name="textAllCaps">false</item>
文本在较旧的机器人上始终为大写。当然,它适用于较新的 API。
我只想将 API 的老书名也大写。
如果您将以下行添加到 TabLayout,它应该可以工作:
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
Android 4.0 中选项卡视图的默认主题(Holo 主题)有android:textAllCaps set to true.
所以你不能不重写 tablayout 样式。如果你没有它,只需添加它,因为它是为了与 viewpager
一起使用
<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
<item name="textAllCaps">false</item>
</style>
并使用
实现它
<android.support.design.widget.TabLayout
app:tabTextAppearance="@style/MyCustomTextAppearance"
.../>
由于没有对我有用的解决方案,最后我这样解决了:
在我的styles.xml到<style name="Base.Widget.Design.TabLayout" parent="@android:style/Theme.Holo">
我刚放
<item name="android:actionBarTabTextStyle">@style/My.TabText.Style</item>
然后在下面:
<style name="My.TabText.Style" parent="@android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textAllCaps">false</item>
</style>
这是唯一适合我的解决方案!
所以重点是添加 android:actionBarTabTextStyle
而不是 tabTextAppearance
也许没什么大不了的,但我无法让它工作。我有一个选项卡导航,我将 strings.xml 中的选项卡标题作为数组:
String[] tbTitles= resources.getStringArray(R.array.tabname);
for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
actionBar.addTab(
actionBar.newTab()
.setText(tbTitles[i])
.setTabListener(this));
}
}
选项卡名称被定义为小写(或者更准确地说是大写 - 示例)。它工作正常,但问题出在较旧的 API 上,其中每个选项卡标题都是大写的。
我在这个论坛上浏览了一些解决方案,但没有找到任何解决方案。
我试着把它放在我的 for 循环中:
tbTitles[i] = tbTitles[i].toLowerCase();
我也试过把它放到我的 tablayout 样式中 styles.xml:
<item name="textAllCaps">false</item>
文本在较旧的机器人上始终为大写。当然,它适用于较新的 API。
我只想将 API 的老书名也大写。
如果您将以下行添加到 TabLayout,它应该可以工作:
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
Android 4.0 中选项卡视图的默认主题(Holo 主题)有android:textAllCaps set to true.
所以你不能不重写 tablayout 样式。如果你没有它,只需添加它,因为它是为了与 viewpager
<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
<item name="textAllCaps">false</item>
</style>
并使用
实现它<android.support.design.widget.TabLayout
app:tabTextAppearance="@style/MyCustomTextAppearance"
.../>
由于没有对我有用的解决方案,最后我这样解决了:
在我的styles.xml到<style name="Base.Widget.Design.TabLayout" parent="@android:style/Theme.Holo">
我刚放
<item name="android:actionBarTabTextStyle">@style/My.TabText.Style</item>
然后在下面:
<style name="My.TabText.Style" parent="@android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textAllCaps">false</item>
</style>
这是唯一适合我的解决方案!
所以重点是添加 android:actionBarTabTextStyle
而不是 tabTextAppearance