相关疑难解决方法(0)

RecyclerView项目中的背景选择器

我正在使用RecyclerView下面的代码:

<android.support.v7.widget.RecyclerView
    android:id="@+id/list"
    android:layout_width="320dp"
    android:layout_height="match_parent"/>
Run Code Online (Sandbox Code Playgroud)

和我的清单项目:

<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>
Run Code Online (Sandbox Code Playgroud)

详细看这部分android:background="@drawable/selector_medium_high"它是一个普通的选择器:

<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>
Run Code Online (Sandbox Code Playgroud)

但是当我运行这段代码时,触摸行时我的背景颜色没有变化....

android selector android-recyclerview

39
推荐指数
6
解决办法
6万
查看次数

标签 统计

android ×1

android-recyclerview ×1

selector ×1