Android水波纹效果
16lz
2021-12-04
原文1链接http://www.aoaoyi.com/archives/677.html
Android 中Layout布局实现点击水波纹效果
从Android5.0以后Button、TabLayout等控件默认都有点击水波纹效果,那像LinearLayout、RelativeLayout、TableLayout、FrameLayout、AbsoluteLayou怎么实现这种效果呢?
方式1:使用 ripple,这个API-21才有。
方式2:使用 RippleEffect或material-ripple,都是第三方优秀方案。
方式3:android:background="?attr/selectableItemBackground",简单、简洁。
我提倡使用方式3,不过使用的过程中需要注意一些问题:
1)、设置下面属性android:clickable="true" android:focusable="true";
2)、Layout实现View.OnClickListener();
3)、API 7+ (Android + AppCompat Support Library):实现方式是:android:background=“?attr/selectableItemBackground”;
=============================================
原文2链接http://blog.csdn.net/u012045061/article/details/50973425
如果的想要你的波纹没有按压的时候为透明状态,下面的写法是无效的.会导致按压没有效果
<?xml version="1.0" encoding="utf-8"?><ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/deep_green">//这里是扩散水波纹的色值 <item android:drawable="@android:color/transparent" />//这里你用透明色和透明的图片都是没有效果的ripple>
正确的做法如下:
<?xml version="1.0" encoding="utf-8"?><ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/deep_green">//这里是扩散水波纹的色值 <item android:id="@android:id/mask" android:drawable="@color/white" />里面的色值可以任选一个ripple>
android:id=”@android:id/mask”会让系统并不会真的绘制,并告知波纹的绘制边界
更多相关文章
- Android开发—利用FrameLayout实现图标中间显示文字
- android2.3 api demo 学习系列(4)--App/Activity/Custom Title
- Android版本更新实现
- Android的多媒体框架OpenCore(PacketVideo)介绍
- android UI进阶之弹窗的使用(2)--实现通讯录的弹窗效果
- Android关于RecyclerView 设置选中效果和AndroidTV Item选中效果
- Android使用FFmpeg(五)--ffmpeg实现音频播放(使用openSL ES进行
- Android动画中Interpolator 加速器的使用
- Android之Telephony各文件解释