通常の波紋を表示するボタンを使用していますが、フチなしの波紋に変更すると機能しません。このリップルが常に機能するようにするには、レイアウト内のボタンの位置をどこにする必要がありますか? 現在は相対レイアウトの内側にあり、画像、ボタンなどを含む他の相対レイアウトの上にあります。
3324 次
1 に答える
1
あなたの問題を簡単に解決できるライブラリを作りました
https://github.com/xgc1986/RippleViews
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn1"
android:background:"the color of the button that you want, that important for your case"
android:text="Default android button"/>
そしてJavaで
View b1 = findViewById(R.id.btn1);
b1.setBackground(RippleDrawableHelper.createRippleDrawable(b1, rippleColor));
ここにドキュメントがあります: https://github.com/xgc1986/RippleViews/blob/master/docs/RippleDrawableHelper.md
編集
View b1 = findViewById(R.id.btn1);
// this may work
View v2 = findViewById(R.id.parent); //the are where the ripple effect extends
//change the view you send in the function
b1.setBackground(RippleDrawableHelper.createRippleDrawable(v2, rippleColor));
これが機能する場合は、ビューの RippleDrawable を作成するためですが、このドローアブルを別のビューに割り当てることができます。その後、b1 ビューを押すと、v2 に関連するリップルが表示されます
于 2015-03-17T14:54:07.877 に答える