水波纹效果的实现

    xiaoxiao2021-03-26  29

    转载请注明本文出自woochen123的博客(http://blog.csdn.net/chewu1590/article/details/54881257),请尊重他人的辛勤劳动成果,谢谢!

    实现:

    在最新的5.0中,google似乎不推荐使用Material Design主题了,而是由AppCompat代替。

    1. <resources>  

    2.   

    3.     <!-- Base application theme. -->  

    4.     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">  

    5.         <!-- Customize your theme here. -->  

    6.         <item name="colorPrimary">@color/colorPrimary</item>  

    7.         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>  

    8.         <item name="colorAccent">@color/colorAccent</item>  

    9.     </style>  

    10.   

    11. </resources>  

    注意事项:

    1.系统默认控件自带波纹效果

    2.非默认控件实现:

    android:background="?android:attr/selectableItemBackground"波纹有边界

    android:background="?android:attr/selectableItemBackgroundBorderless"波纹超出边界

     

    配色方案一(代码):

    android:colorControlHighlight:设置波纹颜色

    android:colorAccent:设置checkbox等控件的选中颜色

    statusBarColor设置状态栏的颜色

     

    配色方案二(Android Studio):

    Tools-Android-themeEditor

    自定义水波纹:

    <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/home_bar_on_bg"> <!--控件未点击时的颜色--> <item android:drawable="@color/white"></item> </ripple>

    更多信息敬请关注微信:

     

     

    转载请注明原文地址: https://ju.6miu.com/read-660706.html

    最新回复(0)