【问题标题】:How to change the size and font of a text in aTabItem (TabLayout)?如何更改aTabItem(TabLayout)中文本的大小和字体?
【发布时间】:2019-02-14 16:05:18
【问题描述】:

我用 3 个项目创建了TabLayout(中间的项目不是图标,而是文本)。

我怎样才能改变文字的大小和他的字体?

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    app:tabTextColor="#777777"
    app:tabIndicatorColor="@color/hellrot"
    app:tabSelectedTextColor="@color/hellrot"
    app:tabIconTint="@color/your_color_selector"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
>

<android.support.design.widget.TabItem
    android:id="@+id/tabItem"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:icon="@drawable/ic_wc_black_24dp" />

<android.support.design.widget.TabItem
    android:id="@+id/tabItem2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Main"
/>

<android.support.design.widget.TabItem
    android:id="@+id/tabItem3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:icon="@drawable/ic_tag_faces_black_24dp" 
/>

</android.support.design.widget.TabLayout>

【问题讨论】:

    标签: android android-layout android-tablayout


    【解决方案1】:

    在styles.xml中写下这些代码

    例子:

    <style name="MyTabItem" parent="TextAppearance.AppCompat.Button">
        <item name="android:textSize">18sp</item>
    </style>
    

    在你的 TabItem 中,设置如下样式。

    <android.support.design.widget. TabItem
     style="@style/MyTabItem"
     android:layout_width="width"
     android:layout_height="height"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-10
      • 1970-01-01
      • 2011-03-30
      相关资源
      最近更新 更多