【问题标题】:How to Create a custom tab layout that mimics the default tab text如何创建模仿默认选项卡文本的自定义选项卡布局
【发布时间】:2018-03-30 19:29:42
【问题描述】:

我需要创建自定义选项卡布局,但我希望文本模仿普通TabLayout.TabView 中使用的样式。

为此,我将文本外观设置为TextAppearance.Design.Tab

如果你看一下TabLayout 本身,你会发现TabView 的文字使用的是这样的:

mTabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab);

...

TextViewCompat.setTextAppearance(mTextView, mTabTextAppearance);

但是,当我的标签显示时,我可以清楚地看到不一样的文字。它非常相似,但默认选项卡看起来更粗。

我做错了什么?

【问题讨论】:

    标签: android android-tablayout


    【解决方案1】:

    答案是以编程方式设置文本外观。在 XML 文件中的 TextView 上设置 android:textAppearance 似乎没有任何作用。以编程方式设置文本外观(如TabLayout.TabView)有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-23
      • 1970-01-01
      • 2022-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多