shape画圆点

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >

    <solid android:color="#33000000" />

    <corners android:radius="5dip" />

</shape>



<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >

    <solid android:color="#aaFFFFFF" />

    <corners android:radius="5dip" />

</shape>


安卓圆点呼吸动可以使用属性动实现,具体步骤如下: 1. 在布局文件中添加一个圆点视图: ```xml <View android:id="@+id/dot" android:layout_width="20dp" android:layout_height="20dp" android:layout_centerInParent="true" android:background="@drawable/dot_bg" /> ``` 其中 `@drawable/dot_bg` 是圆点的背景样式,可以自定义。 2. 在代码中使用属性动实现圆点大小和透明度的变化: ```java // 获取圆点视图 View dotView = findViewById(R.id.dot); // 创建属性动对象,设置动属性为 scaleX、scaleY、alpha ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder( dotView, PropertyValuesHolder.ofFloat("scaleX", 1.0f, 1.3f, 1.0f), PropertyValuesHolder.ofFloat("scaleY", 1.0f, 1.3f, 1.0f), PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.3f, 1.0f) ); // 设置动时长和重复次数 animator.setDuration(1500); animator.setRepeatCount(ValueAnimator.INFINITE); // 开始动 animator.start(); ``` 3. 创建自定义的圆点背景样式 `dot_bg.xml`,实现圆点变大和透明度降低的效果: ```xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <size android:width="20dp" android:height="20dp" /> <solid android:color="@color/colorAccent" /> <alpha android:fromAlpha="1.0" android:toAlpha="0.3" android:duration="1500" android:repeatCount="infinite" android:repeatMode="reverse" /> <scale android:fromXScale="1.0" android:toXScale="1.3" android:fromYScale="1.0" android:toYScale="1.3" android:pivotX="50%" android:pivotY="50%" android:duration="1500" android:repeatCount="infinite" android:repeatMode="reverse" /> </shape> ``` 其中 `alpha` 和 `scale` 标签分别实现了透明度和大小的变化效果,`duration` 表示动时长,`repeatCount` 表示重复次数,`repeatMode` 表示重复模式。 运行程序即可看到圆点呼吸动效果。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值