如何使TabLayout文本大小相等? [英] How to make tablayout text size equal?
本文介绍了如何使TabLayout文本大小相等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这就是我所做的:我为文本创建了样式
Here is what I did: I created a style for the text
<!-- Change tab text appearance -->
<style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
<item name="textAllCaps">false</item>
<item name="android:textAppearance">@style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText"
parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">16sp</item>
</style>
然后将其设置为我的布局
then I set it to my tablayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.HomeActivity"
tools:showIn="@layout/app_bar_main">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:titleTextColor="#ffffff"
/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
app:tabSelectedTextColor="#ffffff"
app:tabTextAppearance="@style/MyCustomTextAppearance"
app:tabTextColor="#ffffff" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout" />
</RelativeLayout>
这是结果:
如您所见,"D日结束"文本比其他文本小.我要求使其大小与其他人相等,但我不知道如何.请帮助我,谢谢.
As you can see, the "D-day complete" text is smaller than others. I have request to make its size equal to others but I dont know how. Please help me, thanks.
推荐答案
您可以尝试在TabLayout中设置填充(app:tabPaddingStart =-1dp",app:tabPaddingEnd =-1dp")
You can try to set padding in TabLayout (app:tabPaddingStart="-1dp", app:tabPaddingEnd="-1dp")
喜欢
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
app:tabSelectedTextColor="#ffffff"
app:tabTextAppearance="@style/MyCustomTextAppearance"
app:tabTextColor="#ffffff"
app:tabPaddingStart="-1dp"
app:tabPaddingEnd="-1dp"/>
它帮助了我
这篇关于如何使TabLayout文本大小相等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文