gpt4 book ai didi

android - 如何使 tablayout 文本大小相等?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:15:56 25 4
gpt4 key购买 nike

这是我所做的:我为文本创建了一个样式

<!-- 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>

然后我将它设置为我的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>

结果如下:

enter image description here

如您所见,“D-day complete”文本比其他文本小。我要求使其大小与其他大小相同,但我不知道如何。请帮助我,谢谢。

最佳答案

可以尝试在TabLayout中设置padding(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"/>

它帮助了我)

关于android - 如何使 tablayout 文本大小相等?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36399013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com