Meterial Design 自带水波纹颜色修改和reveal(揭露)动效

第一部分:.Meterial Design自带水波纹介绍,支持Android 5.0以上,介绍的是自带的水波纹效果,水波纹效果跟主题有关。先看简单效果:
这里写图片描述

布局文件的代码如下:

 <Button
        android:layout_width="200dp"
        android:layout_height="60dp"
        android:text="@string/app_name" />

    <Button
        android:layout_marginTop="10dp"
        android:layout_width="200dp"
        android:layout_height="60dp"
        android:background="?android:attr/selectableItemBackgroundBorderless"
        android:text="@string/app_name" />

    <Button
        android:layout_marginTop="10dp"
        android:layout_width="200dp"
        android:layout_height="60dp"
        android:background="?android:attr/selectableItemBackground"
        android:text="@string/app_name" />

注意:1.默认的按钮背景颜色和水波纹颜色都被修改了,可以再主题里面自定义颜色。
2.注意后面两个按钮的水波纹效果,分别是外接圆和内切圆


//更改点击水波纹效果颜色
 <item name="android:colorControlNormal">@android:color/holo_blue_light</item>
 //更改长按水波纹效果
<item name="android:colorControlHighlight">@android:color/holo_blue_dark</item>
//更改按钮默认的背景颜色
<item name="android:colorButtonNormal">@android:color/holo_green_dark</item>

第二部分:reveal 效果,揭露动画
Meterial Design 自带效果非常酷炫,从效果上来说,Android 5.0在UI上简直是质的飞跃,先看效果图,模拟器有点卡,实际效果是酷毙了
这里写图片描述
改变起始点坐标后的效果
这里写图片描述
主要代码和参数解释如下:

   /**
                 * @param view 目标view.
                 * @param centerX
                 * @param centerY
                 * @param startRadius The starting radius of the animating circle.
                 * @param endRadius The end
                 */
                //这个方法的参数意思算是见名知意
                int centerX = content.getWidth() / 2;
                int centerY = content.getHeight() / 2;
                float startRaius = 0.0f;
                float endRadius = (float) Math.hypot(centerX * 1.0, centerY * 1.0);//勾股定理
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                    Animator animator = ViewAnimationUtils.createCircularReveal(content, centerX, centerY, startRaius, endRadius);
                    animator.setInterpolator(new AccelerateInterpolator());
                    animator.setDuration(1500);
                    animator.start();
                }
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值