一手遮天 Android - view(进度类): ProgressBar 样式
示例如下:
/view/progress/ProgressBarDemo2.java
/**
* ProgressBar - 进度条控件
* setIndeterminateDrawable() - 设置圈圈进度条的样式
* setProgressDrawable() - 设置长条进度条的样式
*/
package com.webabcd.androiddemo.view.progress;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.webabcd.androiddemo.R;
public class ProgressBarDemo2 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_progress_progressbardemo2);
}
}
/layout/activity_view_progress_progressbardemo2.xml
<?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">
<!--
ProgressBar - 进度条控件
indeterminateDrawable - 圈圈进度条的样式(参见 drawable/layerlist_progressbar_indeterminate, drawable/rotate_progressbar_indeterminate, drawable/animationlist_progressbar_indeterminate)
indeterminateDuration - 圈圈旋转一圈所用的时间(单位:毫秒)
progressDrawable - 长条进度条的样式(参见 drawable/layerlist_progressbar_progress)
-->
<!--
旋转一个图片
-->
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:indeterminateDrawable="@drawable/layerlist_progressbar_indeterminate"
android:indeterminateDuration="1500"/>
<!--
旋转一个矢量图形
-->
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:indeterminateDrawable="@drawable/rotate_progressbar_indeterminate"
android:indeterminateDuration="1500"/>
<!--
帧动画
注:对于帧动画来说,设置 indeterminateDuration 属性无效,因为每帧的显示时长是通过 animation-list 的 item 的 duration 来指定的
-->
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:indeterminateDrawable="@drawable/animationlist_progressbar_indeterminate"/>
<!--
长进度条
-->
<ProgressBar
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:min="0"
android:max="100"
android:progress="30"
android:secondaryProgress="50"
android:progressDrawable="@drawable/layerlist_progressbar_progress"/>
</LinearLayout>