开发者

Android Listview Focus with child view as background

In my app i'm setting background to each child views in listview. So that listview default focus ( orange color ) is not focusing.

Is there any way to set both ( listview focus & child view background ) ?..

Edit: This is my code:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="schemas.android.com/apk/res/android">;
    <item android:state_focused="true开发者_开发知识库" 
    android:state_pressed="false" 
    android:drawable="@drawable/img_focused" /> 

    <item android:state_focused="true" 
    android:state_pressed="true" 
    android:drawable="@drawable/img_selected" /> 

    <item android:state_focused="false" 
    android:state_pressed="true" 
    android:drawable="@drawable/img_selected" />

    <item android:drawable="@drawable/img_default" />
</selector>


You can try following states sort order:

<item android:drawable="@drawable/poster_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/poster_focused" android:state_focused="true"/>


It is possible if you define the item background as StateListDrawable. In XML it's done with selector

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜