我正在使用操作栏实现选项卡,但我无法更改选项卡的背景颜色可以帮助我。
提前致谢。
我的输出
我需要的输出
对于那个底部剥离红色,我使用下面的代码
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- STATES WHEN BUTTON IS NOT PRESSED -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
android:state_pressed="false"
android:drawable="@color/transparent" />
<item android:state_focused="false" android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/tab_selected_example" />
<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/tab_unselected_focused_example" />
<item android:state_focused="true" android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/tab_selected_focused_example" />
<!-- STATES WHEN BUTTON IS PRESSED -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
android:state_pressed="true"
android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="false" android:state_selected="true"
android:state_pressed="true"
android:drawable="@drawable/tab_selected_pressed_example" />
<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
android:state_pressed="true"
android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="true" android:state_selected="true"
android:state_pressed="true"
android:drawable="@drawable/tab_selected_pressed_example" />
</selector>
将大写更改为小 文本在 Sherlock 的操作栏选项卡中全部大写
<style name="My.TabText.Style" parent="@android:style/Widget.Holo.Light.ActionBar.TabText">
<item name="android:textAllCaps">false</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">normal</item>
</style>
更改操作颜色和选项卡颜色
// set background for action bar
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0c2354")));
// set background for action bar tab
bar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#B5C0D0")));