在RecyclerView项目背景选择背景、项目、RecyclerView

由网友(穷极一生)分享简介:我使用了 RecyclerView 象下面这样:和我的列表项:...

我使用了 RecyclerView 象下面这样:

<android.support.v7.widget.RecyclerView
    android:id="@+id/list"
    android:layout_width="320dp"
    android:layout_height="match_parent"/>

和我的列表项:

<LinearLayout  android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/selector_medium_high">
    <com.basf.suvinil.crie.ui.common.widget.CircleView
        android:id="@+id/circle"
        android:layout_width="22dp"
        android:layout_height="22dp"/>
    <TextView
        android:id="@+id/label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="57.5dp"/>
</LinearLayout>

详细

看这部分安卓背景=@可绘制/ selector_medium_high这是一个正常的选择:

see in detail this part android:background="@drawable/selector_medium_high" it's a normal selector:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/background_high" android:state_activated="true"/>
    <item android:drawable="@color/background_high" android:state_pressed="true"/>
    <item android:drawable="@color/background_high" android:state_checked="true"/>
    <item android:drawable="@color/background_high" android:state_focused="true"/>
    <item android:drawable="@color/background_medium"/>
</selector>

但是当我运行此code,我在背景颜色没有改变,当我接触的行....

but when I run this code, i have no changes in background color when I touch the row....

推荐答案

在my_list_view的所有元素集点击,可聚焦,focussableInTouchMode为true。

Set clickable, focusable, focussableInTouchMode to true in all elements of "my_list_view".

阅读全文

相关推荐

最新文章