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

在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);

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。