好吧,我永远失去了更多的理智。我无法找到/理解如何设计这该死的东西。 我设法更改了标签本身的背景,但我不能改变所选标签下栏的颜色。
如何将其从蓝色更改为某种东西。
我的styles.xml很遗憾,我对它的工作原理非常不了解
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Styled" parent="Theme.Sherlock.Light">
<item name="actionBarTabStyle">@style/Widget.Styled.ActionBarTab</item>
<item name="android:actionBarTabStyle">@style/Widget.Styled.ActionBarTab</item>
<item name="actionBarTabBarStyle">@style/Widget.Styled.ActionBarTabBar</item>
<item name="android:actionBarTabBarStyle">@style/Widget.Styled.ActionBarTabBar</item>
<item name="actionBarTabTextStyle">@style/myText</item>
<item name="android:actionBarTabTextStyle">@style/myText</item>
</style>
<style name="Widget.Styled.ActionBarTab" parent="Widget.Sherlock.Light.ActionBar.TabView">
<!-- <item name="background">@drawable/startbcg</item>
<item name="android:background">@drawable/startbcg</item>
<item name="backgroundSplit">@drawable/bg_striped_split</item>
<item name="android:backgroundSplit">@drawable/bg_striped_split</item>
-->
</style>
<style name="Widget.Styled.ActionBarTabBar" parent="Widget.Sherlock.Light.ActionBar.TabBar">
<item name="background">@drawable/startbcg</item>
<item name="android:background">@drawable/startbcg</item>
<item name="backgroundSplit">@drawable/bg_striped_split</item>
<item name="android:backgroundSplit">@drawable/bg_striped_split</item>
</style>
<style name="myText" parent="Widget.Sherlock.Light.ActionBar.TabText">
<item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
<item name="android:textColor">@android:color/primary_text_dark</item>
<item name="android:textSize">10sp</item>
</style>
<style name="myTextInv" parent="Widget.Sherlock.Light.ActionBar.TabText.Inverse">
<item name="android:textAppearance">@android:style/TextAppearance.Medium</item>
<item name="android:textColor">@android:color/primary_text_dark</item>
<item name="android:textSize">10sp</item>
</style>
</resources>
奖金问题:我可以在哪里找到某些属性(如背景)。
答案 0 :(得分:17)
使用ActionbarStyleGenerator设置操作栏的样式。这是迄今为止最简单,最直观的方式。
如何:
答案 1 :(得分:8)
我发现,对于后台,最好复制Android SDK res目录中的drawables(9个补丁和xml),并将其更改为你喜欢的颜色。
他们使用包含底栏的背景,所以我认为不可能单独更改底栏。
这就是我所拥有的,使用绿色底部栏:
<style name="customTabStyle" parent="Widget.Sherlock.ActionBar.TabView">
<item name="android:showDividers">none</item>
<item name="android:measureWithLargestChild">true</item>
<!-- This was a copy from the sdk drawable -->
<item name="android:background">@drawable/tab_indicator</item>
<item name="background">@drawable/tab_indicator</item>
<item name="android:gravity">center</item>
<item name="android:textStyle">normal</item>
</style>
<style name="customTabBar" parent="Widget.Sherlock.ActionBar.TabBar">
<item name="android:showDividers">middle</item>
<item name="android:divider">@drawable/tab_divider</item>
<item name="divider">@drawable/tab_divider</item>
<item name="android:dividerPadding">10dip</item>
<item name="android:background">@drawable/tab_bg</item>
</style>
标签指示符如下所示:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed" />
</selector>
我希望它有所帮助!