我试图做这样的事情是什么WordPress的Android应用是做: https://play.google.com/store/apps/details?id=org.wordpress.android的Android留在选中的列表项边框列表视图
我在抽屉式导航的列表视图。当通过使用选择器资源选择项目时,我设法改变背景。如何在所选项目的左侧制作一个小的彩色矩形?像WordPress的应用程序。
编辑:
我的列表项布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/drawer_background_selector"
android:orientation="horizontal" >
<ImageView
android:id="@+id/drawer_item_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp" />
<TextView
android:id="@+id/drawer_item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="8dp" />
</LinearLayout>
我的选择:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/drawer_selected" android:state_activated="true"/>
<item android:drawable="@color/drawer_selected" android:state_selected="true"/>
<item android:drawable="@color/drawer_selected" android:state_pressed="true"/>
<item android:drawable="@color/drawer"/>
</selector>
您可以发布您选择的XML和资源? – ChristopheCVB
嗨!我只是补充道:D –
看看那个页面:http://developer.android.com/guide/topics/resources/drawable-resource.html和Shape资源来创建一个你想要的drawable。 – ChristopheCVB