选择时,请更改操作的背景色(ActionBarSherlock) [英] Change action background color when selected (ActionBarSherlock)
本文介绍了选择时,请更改操作的背景色(ActionBarSherlock)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想改变操作的背景图标的颜色,当它是pressed。
I want to change the color of the action background icon when it is pressed.
我尝试以下,但没有结果:
I tried the following but no results:
styles.xml
<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
<!-- <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item> -->
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="actionBarItemBackground">@drawable/action_item_background</item>
<item name="selectableItemBackground">@drawable/action_item_background</item>
</style>
action_item_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FF0000"/>
</shape>
我怎样才能做到这一点?
How can I achieve that?
推荐答案
这是我找到的解决方案是:
The solution that I found was:
action_item_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FF0000"/>
</shape>
action_item_background_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_shortAnimTime" >
<item
android:state_pressed="true"
android:drawable="@drawable/action_item_background" />
<item
android:drawable="@android:color/transparent" />
</selector>
styles.xml
<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
<item name="actionBarItemBackground">@drawable/action_item_background_selector</item>
<item name="android:actionBarItemBackground">@drawable/action_item_background_selector</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
//...
</style>
这篇关于选择时,请更改操作的背景色(ActionBarSherlock)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文