gpt4 book ai didi

android - 选择时更改操作背景颜色(ActionBarSherlock)

转载 作者:行者123 更新时间:2023-11-29 14:25:02 25 4
gpt4 key购买 nike

我想在按下时更改操作背景图标的颜色。

我尝试了以下但没有结果:

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>

我怎样才能做到这一点?

最佳答案

我找到的解决方案是:

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>

关于android - 选择时更改操作背景颜色(ActionBarSherlock),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17263059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com