一,布局为

<?xml version="1.0" encoding="utf-8"?>        
二, test_shape 对应shape为

   
<?xml version="1.0" encoding="utf-8"?>                

其中,对应属性
   
首先,shape根元素有些属性只适用于ring类型,先过目下这些属性吧:android:innerRadius 内环的半径android:innerRadiusRatio 浮点型,以环的宽度比率来表示内环的半径,默认为3,表示内环半径为环的宽度除3该值会被android:innerRadius覆盖android:thickness 环的厚度android:thicknessRatio 浮点型,以环的宽度比率来表示环的厚度,默认为9,表示环的厚度为环的宽度除以9,该值会被android:thickness覆盖android:useLevel 一般为false,否则可能环形无法显示,只有作为LevelListDrawable使用时才设为true

三,对应,Activity为
   
public class Main19Activity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main19);        ImageView imageView = findViewById(R.id.imageview);        RotateDrawable animationDrawable = (RotateDrawable) imageView.getDrawable();        ValueAnimator valueAnimator = ValueAnimator.ofInt(0, 10000);        valueAnimator.setDuration(4000);        valueAnimator.setInterpolator(new LinearInterpolator());        valueAnimator.setRepeatCount(ValueAnimator.INFINITE);        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {            @Override            public void onAnimationUpdate(ValueAnimator animation) {                Integer animatedValue = (Integer) animation.getAnimatedValue();                animationDrawable.setLevel(animatedValue);            }        });        valueAnimator.start();    }}

四,效果图
   




更多相关文章

  1. Android中自定义TextView的形状--圆形-椭圆形-圆角矩形-线条
  2. android:weight的使用
  3. Android百度地图开发(三)范围搜索
  4. android 自定义进度条
  5. android 随手记-画虚线
  6. android设置在ListView中让TextView滚动
  7. Android使用VideoView全屏播放视频拉伸变形解决办法
  8. shape的使用总结
  9. Android中Shape和Selector的结合使用。

随机推荐

  1. Android(安卓)ListView详解
  2. Android:SQLite数据库
  3. 解决“Cannot merge new index 67208 int
  4. 如何让多行的EditText光标从最前头开始?
  5. 用于 Android(安卓)开发的 Kotlin:是重量
  6. Android(安卓)RadioGroup中设置默认选中R
  7. Android:异步加载网络资源
  8. 【Android(安卓)基础】 android Xml 解析
  9. Android调用系统Camera录像时不能指定保
  10. 【整理】学习Android(安卓)Studio时遇到