导航抽屉:自定义选定的对象背景

时间:2013-09-06 13:18:17

标签: android android-listview navigation-drawer

我想在导航抽屉菜单中选择一个项目时重现此效果:

enter image description here

我该怎么做?

我想在左边有一个小蓝色的banier,在右边有一个黑暗的背景。

1 个答案:

答案 0 :(得分:0)

使用不同的可绘制图像创建一个选择器以指示不同的状态。您想要的特定状态是激活状态,但您也需要覆盖其他状态。

选择器的一个例子就像这样

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/btn_price_normal_market" android:state_enabled="true" 
    android:state_focused="false" android:state_pressed="false"/>
    <item android:drawable="@drawable/btn_price_pressed_market" android:state_pressed="true"/>
    <item android:drawable="@drawable/btn_price_focused_market" android:state_focused="true"/>
</selector>