android之修改系统自带ProgressDialog样式

1.ProgressDialog默认样式是当前Activity的theme所定义的ProgressDialog样式。

  继承自父类AlertDialog的style.

AlertDialog的源码

     static int resolveDialogTheme(Context context, int resid) {
        if (resid == THEME_TRADITIONAL) {
            return com.android.internal.R.style.Theme_Dialog_Alert;
        } else if (resid == THEME_HOLO_DARK) {
            return com.android.internal.R.style.Theme_Holo_Dialog_Alert;
        } else if (resid == THEME_HOLO_LIGHT) {
            return com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert;
        } else if (resid == THEME_DEVICE_DEFAULT_DARK) {
            return com.android.internal.R.style.Theme_DeviceDefault_Dialog_Alert;
        } else if (resid == THEME_DEVICE_DEFAULT_LIGHT) {
            return com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog_Alert;
        } else if (resid >= 0x01000000) {   // start of real resource IDs.
            return resid;
        } else {
            TypedValue outValue = new TypedValue();
            context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme,
                    outValue, true);
            return outValue.resourceId;
        }
    }

         2.引用系统的样式,引用不到com.android.internal.R.style.Theme_Holo_Dialog_Alert,而是通过ProgressDialog.THEME_HOLO_LIGHT来引用系统自定义ProgressDialog样式。

ProgressDialog dialog = new ProgressDialog(this, ProgressDialog.THEME_HOLO_LIGHT);
dialog.setTitle("登录");
dialog.setMessage("正在登录,请稍后...");
// dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(true);
dialog.show();


       3.引用自定义ProgressDialog样式

转自http://www.2cto.com/kf/201309/241455.html

转自http://blog.csdn.net/rohsuton/article/details/7518031

转自http://blog.csdn.net/luhuajcdd/article/details/8986212

        转自http://blog.csdn.net/qjlhlh/article/details/7979179




你可能感兴趣的:(android之修改系统自带ProgressDialog样式)