自定义等待进度条实现

xml

ProgressBar
<ProgressBar
android:id="@+id/progress"
android:layout_width="30dp"
android:layout_height="30dp"
android:indeterminateBehavior="repeat"//重复
android:layout_gravity="center"
android:indeterminateDrawable="@drawable/top_loading_progress"
android:indeterminateOnly="true"//是否确定进度值
android:visibility="gone" />
圆环
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadiusRatio="3"//内环的半径比率  默认9
android:shape="ring"        //环的宽度除以Ratio
android:thicknessRatio="24"//环的厚度比率   默认3
android:useLevel="false" >
<gradient
android:centerY="0.50"
android:endColor="#ff6699"
android:startColor="#0affaaff"
android:type="sweep"//扫描式渐变
android:useLevel="false" />
</shape>
旋转
  1. wait for test
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<rotate android:duration="200"
android:fromDegrees="180.0"
android:toDegrees="0.0" 
android:pivotX="50.0%"
android:pivotY="50.0%" />
</set>
  1. animated-rotate
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progress_shape_new"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="359" />

java

1.自定义对话框

public class CustomProgressDialog extends Dialog {
    private Context context = null;
    private static CustomProgressDialog customProgressDialog = null;

    public CustomProgressDialog(Context context) {
        super(context);
        this.context = context;
    }

    public CustomProgressDialog(Context context, int theme) {
        super(context, theme);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    //点击空白部分隐藏进度条
        setCanceledOnTouchOutside(false);
        super.onCreate(savedInstanceState);
    }

    public static CustomProgressDialog createDialog(Context context) {
        customProgressDialog = new CustomProgressDialog(context,
                R.style.CustomProgressDialog);
        customProgressDialog.setContentView(R.layout.customprogressdialog);
        customProgressDialog.getWindow().getAttributes().gravity = Gravity.CENTER;
        return customProgressDialog;
    }

    public void onWindowFocusChanged(boolean hasFocus) {

        if (customProgressDialog == null) {
            return;
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值