0

我正在使用自定義的RecyclerView。在我的RecyclerView行中有兩個項目一個TextView和一個ImageView。當我點擊TextView時,行項顯示了連鎖效應。我爲該佈局設置了連鎖效應,因此點擊顯示連鎖效果的文本視圖。Android:如何控制RecyclerView中的紋波效應

當我點擊shpwing在該行右側​​的圖片時,那麼漣漪效應也會顯示該行的整個佈局。我想要控制。

只有當我按下TextView/Layout時,才需要連鎖效應。當我按下像我想控制的連鎖反應,波及效應應僅在該圖片

Layout.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 

<RelativeLayout 
    android:id="@+id/layout_subdistributorItem" 
    android:layout_width="match_parent" 
    android:layout_height="75dp" 
    android:layout_marginLeft="15dp" 
    android:layout_marginRight="-10dp" 
    android:layout_marginTop="6dp" 
    android:layout_alignParentRight="true" 
    android:background="@drawable/list_background_with_shadow" 
    android:paddingLeft="2dp"> 

    <com.flexiSupport.RippleView 
     xmlns:ripple="http://schemas.android.com/apk/res-auto" 
     android:layout_width="wrap_content" 
     android:layout_height="75dp" 
     ripple:rv_type="rectangle" 

     > 

    <ImageView 
     android:id="@+id/img_activeSubdistributor" 
     android:layout_width="18dp" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:layout_marginLeft="10dp" 

     android:layout_alignParentLeft="true" 
     android:src="@drawable/offline"/> 
    <TextView 
     android:id="@+id/txt_RechargeSubdistributor" 
     android:layout_width="100dp" 
     android:layout_height="40dp" 
     android:layout_centerVertical="true" 
     android:layout_marginRight="30dp" 
     android:layout_marginTop="10dp" 
     android:gravity="center_horizontal|center_vertical" 
     android:textColor="#fff" 
     android:textSize="15dp" 

     android:layout_marginBottom="10dp" 
     android:layout_alignParentRight="true" 
     android:background="@drawable/recharge_text" 
     android:text=""/> 
    <LinearLayout 
     android:id="@+id/layout_subdistributor" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/img_activeSubdistributor" 
     android:layout_toLeftOf="@+id/txt_RechargeSubdistributor" 
     android:paddingLeft="12dp" 
     android:layout_centerVertical="true" 
     android:orientation="vertical"> 
     <TextView 
      android:id="@+id/txt_subDistributorName" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:textSize="15dp" 
      android:textColor="@color/black" 
      android:text="Subdistributor 1" 
      android:maxLength="22" 
      android:typeface="sans" 
      android:layout_marginTop="8dp" 
      android:layout_marginBottom="8dp" 
      /> 
     <TextView 
      android:id="@+id/txt_subDistributorId" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:textSize="15dp" 
      android:visibility="gone" 
      /> 

     <TextView 
      android:id="@+id/txt_subDistributor_number" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:textSize="16dp" 
      android:textColor="@color/black" 
      android:text="99999999" 
      android:maxLength="22" 
      android:typeface="sans" 
      android:layout_marginBottom="8dp" 
      /> 
     </LinearLayout> 
    </com.flexiSupport.RippleView> 
</RelativeLayout> 

這是我的佈局顯示爲

enter image description here

任何人都可以幫我控制漣漪效應

回答

0

嘗試給這個背景,其具有有漣漪效應的圖,

機器人:背景=「機器人:ATTR/selectableItemBackground」