美文网首页
Android 代码设置控件点击水波纹效果

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

作者: Observer_观者 | 来源:发表于2020-05-27 14:37 被阅读0次

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

    相关文章

      网友评论

          本文标题:Android 代码设置控件点击水波纹效果

          本文链接:https://www.haomeiwen.com/subject/vrywahtx.html