Android 代码设置控件点击水波纹效果

2020-05-27  本文已影响0人  Observer_观者

在xml文件种中,设置background 或者 foreground 属性

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

代码设置水波纹效果

attrs = new int[]{android.R.attr.selectableItemBackground};
TypedArray ta = getContext().obtainStyledAttributes(attrs);
Drawable mDefaultFocusHighlightCache = ta.getDrawable(0);
ta.recycle();
textView.setForeground(mDefaultFocusHighlightCache);

上一篇 下一篇

猜你喜欢

热点阅读