【发布时间】:2018-06-24 03:10:20
【问题描述】:
我在 Android 中有这个 TabLayout,并且想让标签比默认的 (48dp) 高一点
<android.support.design.widget.TabLayout
android:id="@+id/contentTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Theme.Zhaw.TabLayout"
app:tabMode="fixed"
app:tabGravity="fill"/>
这里是样式 Theme.Zhaw.TabLayout:
<style name="Theme.Zhaw.TabLayout" parent="Widget.Design.TabLayout">
<item name="tabIndicatorColor">@color/text_white</item>
<item name="tabIndicatorHeight">4dp</item>
<item name="tabPaddingStart">6dp</item>
<item name="tabPaddingEnd">6dp</item>
<item name="tabBackground">@color/colorPrimary</item>
<item name="tabTextAppearance">@style/Theme.Zhaw.TabLayoutText</item>
<item name="tabSelectedTextColor">@color/text_white</item>
</style>
tabIndicatorHeight 可以设置标签中小指示器(活动标签)的高度。但是我们如何设置标签本身的高度呢?
【问题讨论】:
-
只需将高度替换为 android:layout_height="your_height"
-
@HRaval java.lang.RuntimeException:无法启动活动 ComponentInfo{MainActivity}:android.view.InflateException:二进制 XML 文件第 25 行:二进制 XML 文件第 25 行:您必须提供 layout_height属性。