android – 滑动标签布局文本是大写的

前端之家收集整理的这篇文章主要介绍了android – 滑动标签布局文本是大写的前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
嗨,我在我的应用程序中使用滑动选项卡布局,这一切都很好.我唯一不理解的是为什么我的标签文本是大写的.

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

以下是设置文本的类中的代码

  1. private void populateTabStrip() {
  2. final PagerAdapter adapter = mViewPager.getAdapter();
  3. final View.OnClickListener tabClickListener = new TabClickListener();
  4.  
  5. for (int i = 0; i < adapter.getCount(); i++) {
  6. View tabView = null;
  7. TextView tabTitleView = null;
  8.  
  9. if (mTabViewLayoutId != 0) {
  10. // If there is a custom tab view layout id set,try and inflate it
  11. tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId,mTabStrip,false);
  12. tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
  13. }
  14.  
  15. if (tabView == null) {
  16. tabView = createDefaultTabView(getContext());
  17. }
  18.  
  19. if (tabTitleView == null && TextView.class.isInstance(tabView)) {
  20. tabTitleView = (TextView) tabView;
  21. }
  22.  
  23. if (mDistributeEvenly) {
  24. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
  25. lp.width = 0;
  26. lp.weight = 1;
  27. }
  28.  
  29. tabTitleView.setText(adapter.getPageTitle(i));
  30. tabTitleView.setTextColor(getResources().getColor(R.color.da_blue));
  31. tabView.setOnClickListener(tabClickListener);
  32. String desc = mContentDescriptions.get(i,null);
  33. if (desc != null) {
  34. tabView.setContentDescription(desc);
  35. }
  36.  
  37. mTabStrip.addView(tabView);
  38. if (i == mViewPager.getCurrentItem()) {
  39. tabView.setSelected(true);
  40. }
  41. }
  42. }

我敢肯定我可以通过一种风格来做,但实际上不确定使用哪种风格.这就是我的风格:

  1. <resources>
  2.  
  3. <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  4. <item name="android:actionBarTabTextStyle">@style/ActionBarTabTextStyle.Tabtheme</item>
  5. <item name="actionBarTabTextStyle">@style/ActionBarTabTextStyle.Tabtheme</item>
  6. </style>
  7.  
  8.  
  9. <style name="ActionBarTabTextStyle.Tabtheme" parent="@android:style/Widget.Holo.ActionBar.TabText">
  10. <item name="android:textAllCaps">false</item>
  11. </style>
  12. </resources>

解决方法

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

猜你在找的Android相关文章