2017-02-09 4 views
2

を働いていない、これは波及効果は

<RelativeLayout android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:background="?android:attr/selectableItemBackground" 
android:clickable="true" 
android:focusable="true" 
xmlns:android="http://schemas.android.com/apk/res/android" > 
<TextView 
    android:id="@+id/save" 
    android:layout_centerVertical="true" 
    android:text="@string/save" 
    android:textSize="@dimen/text_size" 
    android:textColor="@color/white" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 
<ImageView 
    android:layout_toRightOf="@+id/save" 
    android:layout_centerVertical="true" 
    android:src="@drawable/ic_right_arrow" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /></RelativeLayout> 

リップルが唯一の子ビューの外に動作するレイアウトコードです。どのようにリップルを達成するためにchildviewsを含む全体のレイアウトに影響を与える?あなたはこれが波紋を行います

android:foreground="?android:attr/selectableItemBackground" 

android:background="?android:attr/selectableItemBackground" 

を変更しようとすることができ

+1

セット「アンドロイド:バックグラウンド=」? android:attr/selectableItemBackground ""も同様です。 –

+0

子ビューは、クリックされたときに個別の波紋を持ち、何かがクリックされたときにリップルを持つようにRelativeLayoutを設定しますか? – Rachit

+0

@Rachit noレイアウト全体に1つのリップルが欲しい –

答えて

4

ので、すべてのChildViewsはまた、それらの上に波紋を取得します、RelativeLayoutの最上部に表示されます。

違いはこれです:背景がselectableItemBackgroundとして設定されているRelativeLayout上部に

Click on two RelativeLayouts

、底部に前景がselectableItemBackground

として設定されている一方
+0

ありがとう、android:foreground = "?アンドロイド:attr/selectableItemBackground"レイアウト全体で1つのリップルが動作します –

関連する問題