raj*_*aji 6 android android-theme android-actionbar
我已经坚持了几天这个问题了.任何人都可以帮我自定义ActionBar(NavigationMode NAVIGATION_MODE_TABS)下方显示的选项卡吗?
我基本上想要更改选项卡的背景颜色和当前所选选项卡的下划线颜色.到目前为止,这是我所做的,但它不起作用.我在用ActionBarSherlock.
<style name="Theme.Styled" parent="@style/Theme.Sherlock.Light">
<item name="actionBarStyle">@style/Widget.Theme.Styled.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.Theme.Styled.ActionBar</item>
<item name="actionBarTabBarStyle">@style/customActionBarTabStyle</item>
<item name="android:actionBarTabBarStyle">@style/customActionBarTabStyle</item>
<item name="actionBarTabBarStyle">@style/customActionBarTabBarStyle</item>
<item name="android:actionBarTabBarStyle">@style/customActionBarTabBarStyle</item>
<item name="actionBarTabTextStyle">@style/customActionBarTabTextStyle</item>
<item name="android:actionBarTabTextStyle">@style/customActionBarTabTextStyle</item>
</style>
<style name="customActionBarTabStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabView">
<item name="android:background">@color/red</item>
<item name="android:textSize">12dp</item>
</style>
<style name="customActionBarTabBarStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabBar">
<item name="android:background">@color/red</item>
</style>
<style name="customActionBarTabTextStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabText">
<item name="android:titleTextStyle">@style/Theme.Styled.ActionBar.TitleTextStyle</item>
<item name="android:textStyle">bold</item>
</style>
<style name="Widget.Theme.Styled.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#A9E2F3</item>
<item name="background">#A9E2F3</item>
<item name="android:titleTextStyle">@style/Theme.Styled.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.Styled.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
<item name="android:textStyle">bold</item>
</style>
<style name="Animations" />
Run Code Online (Sandbox Code Playgroud)
Too*_*oop 17
我不确定你是否还需要这个,但我会将答案发给其他人看.您可以在后台设置此Drawable的customActionBarTabStyle作为可绘制资源:
<style name="customActionBarTabStyle" parent="style/Widget.Sherlock.Light.ActionBar.TabView">
<item name="android:background">@drawable/actionbar_tabs_selector</item>
<item name="android:textSize">12dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
资源应该是一个选择器,在这些行中:
<!-- This is the "@drawable/actionbar_tabs_selector" layout !-->
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/actionbar_tab_style_nselected"/>
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/actionbar_tab_style_selected"/>
<!-- Pressed state -->
<item android:state_pressed="true" android:drawable="@drawable/actionbar_tab_style_selected" />
<!-- Focused state -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/actionbar_tab_style_nselected"/>
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/actionbar_tab_style_nselected"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
所以这里的资源是2层列表.一个用于当拉片处于非活动状态,并且一个当选择选项卡和活性.因此,您可以根据所选状态设置2个图层列表.
单个图层列表可能如下所示:
<!-- This is the "@drawable/actionbar_tab_style_nselected" layout !-->
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Bottom Line -->
<item>
<shape android:shape="rectangle">
<solid android:color="@color/HCL_orange" />
</shape>
</item>
<!-- Tab color -->
<item android:bottom="2dip">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
因此,第一项是底线,您可以将其定义为当前所选Tab的下划线颜色,第二项是整个选项卡的颜色.
| 归档时间: |
|
| 查看次数: |
11078 次 |
| 最近记录: |