给ProgressBar 设置圆形进度条颜色

设置圆形进度条的颜色,调用setIndeterminateDrawable(Drawable d)方法

progressDialog = ProgressDialog.show(LoginActivity.this, null, "Loading", true, true);
//设置进度条颜色
progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progressbar));

在drawable目录下建文件名为:progressbar.xml文件


<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:pivotX="50%" android:pivotY="50%"
    android:fromDegrees="0"
    android:toDegrees="360">

    <shape
        android:shape="ring"
        android:innerRadiusRatio="3"
        android:thicknessRatio="8"
        android:useLevel="false">

        <gradient
            android:type="sweep"
            android:useLevel="false"
            android:startColor="#ffffff"
            android:centerColor="#397eff"
            android:centerY="0.50"
            android:endColor="#395eff" />

    shape>
animated-rotate>

你可能感兴趣的:(android)