【发布时间】:2015-04-05 01:25:18
【问题描述】:
我正在尝试自定义 SherlockTabBar,但在更改选项卡背景颜色时遇到了问题。我已经使用了“ActionBarStyle Generator”并从那里复制了我有兴趣更改的资源。现在我设法更改了选定的选项卡指示器,但我不知道如何更改选项卡背景以及选项卡指示器。 我的自定义样式代码如下所示:
<style name="Theme.Custom" parent="style/Theme.Sherlock.Light">
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
</style>
<style name="MyActionBarTabStyle" parent="style/Widget.Sherlock.Light.ActionBar">
<item name="android:background">@drawable/actionbarselector</item>
<item name="android:gravity">center</item>
</style>
和选择器:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_customstyle"/>
<item android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_customstyle" />
<item android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_customstyle" />
</selector>
有什么建议吗?
【问题讨论】:
-
嘿,试试 api 21 中引入的 TOOLBAR,超级好用,你可以修改工具栏的颜色,高度。只是建议另一种选择。检查链接toolbar
-
我被困在 SherlockTabBar 上,使用它不是我的选择。无论如何感谢您的建议。
标签: android actionbarsherlock tabbar