更改选项卡内的文本大小 [英] Changing text size inside Tabs

查看:17
本文介绍了更改选项卡内的文本大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为各种屏幕尺寸设计我的应用程序,但我遇到了一个小问题.我无法更改选项卡内文本的大小.这就是我所做的.

I am designing my app for various screen sizes,but I have a small problem. I can't change the size of the text inside the tabs. Here is what I did.

首先我创建了自己的风格.

Firstly I created my own style.

<style name="MineCustomTabText" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">22sp</item>
</style>

然后我用这个样式来对应的xml文件.

And then I use this style to the appropriate xml file.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="manutd.football.app.interviews.InterviewsActivity">

<manutd.football.app.SlidingTabLayout
    android:id="@+id/tabs"
    app:tabTextAppearance="@style/MineCustomTabText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="2dp"
    android:background="#656e99" />

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_below="@+id/tabs"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:layout_weight="1"
    ></android.support.v4.view.ViewPager>

</RelativeLayout>

有什么想法吗?谢谢

推荐答案

我不知道你为什么选择manutd.football.app.SlidingTabLayout

你可以使用

<android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        style="@style/MyCustomTabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
</android.support.design.widget.TabLayout>

这样你就可以在你的标签中改变你想要的内容,比如

by this you can change what you want in your tabs like

<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
    <item name="tabMaxWidth">@dimen/tab_max_width</item>
    <item name="tabIndicatorColor">?attr/colorAccent</item>
    <item name="tabIndicatorHeight">2dp</item>
    <item name="tabPaddingStart">12dp</item>
    <item name="tabPaddingEnd">12dp</item>
    <item name="tabBackground">?attr/selectableItemBackground</item>
    <item name="tabTextAppearance">@style/MyCustomTabTextAppearance</item>
    <item name="tabSelectedTextColor">?android:textColorPrimary</item>
</style>
<style name="MyCustomTabTextAppearance" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">?android:textColorSecondary</item>
    <item name="textAllCaps">true</item>
</style>

这篇关于更改选项卡内的文本大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆