2017-10-03 2 views
0

RecyclerView 항목에 리플 효과를 추가하려고합니다. 온라인에서 한 번 보았지만 필요한 것을 찾을 수 없었습니다. RecyclerView 자체에 배경 속성과로 설정 : 나는 안드로이드를 시도했다 "안드로이드 : selectableItemBackground"하지만 그것은 작동하지 않았다 :RecyclerView 리플 효과가 작동하지 않습니다.

어댑터 템플리트 아래

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/text_container" 
android:layout_width="match_parent" 
android:layout_height="75dp" 
android:background="?attr/selectableItemBackground" 
android:clickable="true" 
android:focusable="true" 
android:orientation="vertical" 

> 
<TextView 
    android:id="@+id/u_key" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="20dp" 
    android:gravity="left" 
    android:maxLines="1" 
    android:paddingLeft="@dimen/u_common_text_size" 
    android:paddingRight="@dimen/u_common_text_size" 
    android:singleLine="true" 
    android:text="Item" 
    android:textColor="#808080" 
    android:textSize="@dimen/u_common_text_size" /> 

<TextView 
    android:id="@+id/u_value" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:drawablePadding="5dip" 
    android:gravity="left" 
    android:maxLines="1" 
    android:paddingLeft="@dimen/u_common_text_size" 
    android:paddingRight="@dimen/u_common_text_size" 
    android:singleLine="true" 
    android:text="Item" 
    android:textColor="@android:color/black" 
    android:textSize="@dimen/u_common_text_size" /> 



<View 
    android:id="@+id/bottomline" 
    android:layout_width="match_parent" 
    android:layout_height="1dp" 
    android:background="#e6e6e6" 
    android:visibility="gone" /> 

<android.support.v7.widget.RecyclerView 
     android:id="@+id/recyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="5dp" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     /> 
에 표시됩니다

답변

0

LinearLayout 상위 뷰 배경을 보면 배경 속성이 올바르지 않은 것을 보았습니다 (물음표와 : attr 사이에 안드로이드를 잊어 버렸습니다).

android:background="?android:attr/selectableItemBackground" 
관련 문제