I'm desperately trying to create a listfragment that looks similar to the ones used in the googlemail and standard mail app on tablets. For selected entries they have an arrow on the right pointing to the entry. The whole list has a divider line on the right, that drops a shawdow towards the list.
I tried to rebuild this with two means. First a black line-9-patch as a background image for the whole listview. For the arrow I added an ImageView on top of each list item making it float on the right. Everything works fine so far, although I don't know whether this is the most elegant way.
My problem ist the state dependency of the arrow. It should only be visible when the item is selected. I set the "duplicateState" property of the ImageView to duplicate the state of the image. And as a source I added a drawable that uses a selector. I tried all different combinations of states but the image does not show up... Any suggestions?!
This is my list item and my selector-drawable:
- Code: Select all
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="2dp"
android1:src="@drawable/arrow_vis"
android1:visibility="visible" >
</ImageView>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:text="Title"
android:textSize="20dip"
android:textStyle="bold" />
</merge>
- Code: Select all
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_checked="true" android:drawable="@drawable/arrow_empty" />
<item android:state_focused="false" android:state_checked="true" android:drawable="@drawable/arrow" />
</selector>




. The code I posted above is to some degree from the original listBackground-Style. Before I tried out the following code.

