我需要为我的选项卡使用自定义 View ,问题是 fill_parent 不起作用(如 here 所示)。
所以我需要使用边距和其他东西,但是为了让 View 在所有配置(横向/纵向,或在标签高度会改变的平板电脑)中居中显示,这有点棘手.
我不知道在每个配置上使用什么值。另外,我找不到系统开始时使用的默认布局。
最佳答案
我建议您使用 ActionBar Tab 样式。这是干净和简单的。例如(在 TabView 上归零):
<style name="MyActionBar" parent="@style/android:Widget.Holo.ActionBar">
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:attr/actionBarTabTextStyle">@style/MyActionBarTabText</item>
<item name="android:attr/actionBarTabStyle">@style/MyActionBarTabStyle</item>
</style>
<!-- styling for the tabs -->
<style name="MyActionBarTabStyle" parent="@style/android:Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_bar_bg_master</item>
<item name="android:gravity">center</item>
</style>
(我还会注意到,通过使用自定义 Drawable,选项卡的样式可高度调整。但这是另一天的话题!)
关于android - 带有自定义 View 的 ActionBar 选项卡未居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21547292/