gpt4 book ai didi

android - 滑动标签布局文本为大写

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:08:10 24 4
gpt4 key购买 nike

您好,我在我的应用中使用了滑动选项卡布局,一切都很好。我唯一不明白的是为什么我的标签文本是大写的。

我已经打印了选项卡在滑动选项卡类中获得的文本,但它们不是大写的。我环顾四周,没有调用 toUpperCase 方法。

这是设置文本的类中的代码:

  private void populateTabStrip() {
final PagerAdapter adapter = mViewPager.getAdapter();
final View.OnClickListener tabClickListener = new TabClickListener();

for (int i = 0; i < adapter.getCount(); i++) {
View tabView = null;
TextView tabTitleView = null;

if (mTabViewLayoutId != 0) {
// If there is a custom tab view layout id set, try and inflate it
tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip,
false);
tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
}

if (tabView == null) {
tabView = createDefaultTabView(getContext());
}

if (tabTitleView == null && TextView.class.isInstance(tabView)) {
tabTitleView = (TextView) tabView;
}

if (mDistributeEvenly) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
lp.width = 0;
lp.weight = 1;
}

tabTitleView.setText(adapter.getPageTitle(i));
tabTitleView.setTextColor(getResources().getColor(R.color.da_blue));
tabView.setOnClickListener(tabClickListener);
String desc = mContentDescriptions.get(i, null);
if (desc != null) {
tabView.setContentDescription(desc);
}

mTabStrip.addView(tabView);
if (i == mViewPager.getCurrentItem()) {
tabView.setSelected(true);
}
}
}

我确信我可以通过一种风格来做到这一点,但真的不确定该使用哪种风格。这是我的风格:

<resources>

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:actionBarTabTextStyle">@style/ActionBarTabTextStyle.Tabtheme</item>
<item name="actionBarTabTextStyle">@style/ActionBarTabTextStyle.Tabtheme</item>
</style>


<style name="ActionBarTabTextStyle.Tabtheme" parent="@android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textAllCaps">false</item>
</style>
</resources>

最佳答案

如果你使用“android.support.design.widget.TabLayout”需要设置app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"

关于android - 滑动标签布局文本为大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28316454/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com