Android 利用ClipDrawable 自定义进度条
2017-12-28 10:31
225 查看
一,整体布局
二,drawable/drawable_inset 对应资源
三,@drawable/progress_bar 对应shape
四,对应java代码
五,效果图
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="12dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_marginTop="10dp" android:src="@drawable/drawable_inset"/> </LinearLayout>
二,drawable/drawable_inset 对应资源
<?xml version="1.0" encoding="utf-8"?> <clip xmlns:android="http://schemas.android.com/apk/res/android" android:clipOrientation="horizontal" android:drawable="@drawable/progress_bar" android:gravity="left"> </clip >
三,@drawable/progress_bar 对应shape
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/button_normal_color" /> <corners android:radius="8dp"/> </shape>
四,对应java代码
public class Main2Activity extends Activity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.linear_test); ImageView imageView = findViewById(R.id.image); Drawable drawable = imageView.getDrawable(); ValueAnimator valueAnimator = ValueAnimator.ofInt(1,10000); valueAnimator.setDuration(3000); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { drawable.setLevel((int)animation.getAnimatedValue()); } }); valueAnimator.start(); } }
五,效果图
相关文章推荐
- Android中ClipDrawable的使用和自定义ProgressBar
- android 使用clip.xml 作为drawable 作成进度条图片效果
- android ClipDrawable实现进度条
- ProgressBar 自动旋转的图片、进度条 利用android:indeterminateDrawable来实现ProgressBar三种方式
- Android笔记:根据进度代码改变progressbar背景颜色,ClipDrawable,LayerDrawable,setProgressDrawable
- android用ClipDrawable自定义各种进度条(包括竖直和水平)
- Android Clip用法——自定义进度条
- 【Android】利用自定义View的重绘实现拖动移动,获取组件的尺寸
- Android 高手进阶之自定义View,自定义属性(带进度的圆形进度条)
- Android自定义没有资源文件的圆形进度条ProgressBar
- android 进度条 自定义菊花
- Android自定义进度条
- android自定义的弧形进度条和圆形进度条-SemicircleProgress
- Android 自定义ProgressBar--进度自己设置图片
- android自定义ProgressBar 修改进度条样式 出现setProgress无效问题
- android 自定义进度条
- Android自定义菊花进度条
- Android 自定义漂亮的圆形进度条
- android:自定义Material Design风格ProgressDialog的进度框
- Android Drawable Resource学习(九)、ClipDrawable