Android的新手。Android可绘制:state_selected工作,取代state_pressed?
我有以下的在res /定义绘制/在一个菜单按钮在style.xml定义
<style name="menu_icon">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/menu_item_height</item>
<item name="android:background">@drawable/menu_item_bg_sel</item>
</style>
现在,menu_item_bg_sel在绘制有2个状态,我感兴趣的两个不同的颜色渐变压入和选择。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<layer-list>
<item>
<shape>
<gradient android:angle="180"
android:endColor="@color/background_menu_gray_selected2"
android:centerColor="@color/background_menu_gray_selected1"
android:startColor="@color/background_menu_gray_selected" />
</shape>
</item>
</layer-list>
</item>
<item android:state_selected="true">
<layer-list>
<item>
<shape>
<gradient android:angle="180" android:endColor="@color/background_menu_home2"
android:centerColor="@color/background_menu_home1"
android:startColor="@color/background_menu_home" />
</shape>
</item>
</layer-list>
</item>
<item android:drawable="@color/transparent"/>
然而,当我按下按钮(即过渡状态)按钮仍创建梯度服用颜色只从selected_state。
我在做什么错?有任何想法吗?