gpt4 book ai didi

android - 删除 TabLayout 中的换行符

转载 作者:IT王子 更新时间:2023-10-29 00:06:00 24 4
gpt4 key购买 nike

我刚刚将新的 TabLayout 组件添加到我的应用程序中。您可能知道标签 app:tabMode="scrollable"app:tabMode="fixed" 有两种不同的模式。

当我使用 app:tabMode="fixed" 我得到以下结果:

enter image description here

左右两边没有边距/内边距,但文字被换行了。

但是当我使用 app:tabMode="scrollable" 我得到以下结果:

enter image description here

文本未换行,但右侧有一个奇怪的边距,我无法摆脱它。

我也尝试将 tabGravity 设置为 app:tabGravity="center"app:tabGravity="fill" 但没有实现任何更改。

如果你们中的任何一个聪明的男孩和女孩能为我找到解决方案,那就太好了。

干杯,卢卡斯

最佳答案

这是一个快速的 hack,比使用 setCustomView() 短得多:在 TabLayout 上使用 android:theme 属性:

<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TabLayout_Theme"
app:tabMode="fixed"/>

然后在您的主题 XML 中:

<style name="TabLayout_Theme" parent="@style/AppTheme">
<item name="android:singleLine">true</item>
</style>

我们必须这样做,因为不幸的是,在 TabLayout 上设置的 app:tabTextAppearance 上的 android:singleLine 属性被忽略了。 app:tabTextAppearance 实际上只对更改文本大小有用。

关于android - 删除 TabLayout 中的换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31698756/

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