为什么ProgressDialog的背景不设置在透明? [英] Why the background of ProgressDialog doesn't set to the transparent?

查看:1048
本文介绍了为什么ProgressDialog的背景不设置在透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要回地面设置为透明的,所以我已经设置了以下code。在

I want to set the back ground to the transparent , so I have set the following code in

styles.xml
<style name="dialog" parent="@android:style/Theme.Dialog">  
            <item name="android:windowFrame">@null</item>  
            <item name="android:windowIsFloating">true</item>  
            <item name="android:windowContentOverlay">@null</item>  
            <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>  
            <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>  
            <item name="android:windowBackground">@android:color/transparent</item>  
            <item name="android:windowNoTitle">true</item> 
        </style> 

和我有使用 Progressdialog 像下面的code。在 JAVA文件片段

And I have use the Progressdialog like the following code in JAVA file and in fragment.

Activity activity = getActivity() ;
mProgressDialog = new ProgressDialog(activity,R.style.dialog) ;
mProgressDialog.setCancelable(false) ;
mProgressDialog.show() ;

不过,我得到像下面的图片的进步,它不具有透明背景。

But I get the progress like the following picture , and it doesn't has transparent background.

为什么背景不会改变,以透明?

Why the background doesn't change to the transparent ?

推荐答案

创建自定义值的MyTheme \ styles.xml

create custom MyTheme in values\styles.xml

<style name="MyTheme" parent="android:Theme.Holo.Dialog">
    <item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item>
    <item name="android:windowBackground">@color/transparent</item>
    <item name="android:textColorPrimary">#FFFFFF</item>
     <item name="android:backgroundDimEnabled">false</item>
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:textStyle">normal</item>
    <item name="android:textSize">12sp</item>
</style>

和也值添加此 CustomAlertDialogStyle \ styles.xml

And also add this CustomAlertDialogStyle in values\styles.xml

 <style name="CustomAlertDialogStyle">
<item name="android:bottomBright">@color/transparent</item>
<item name="android:bottomDark">@color/transparent</item>
<item name="android:bottomMedium">@color/transparent</item>
<item name="android:centerBright">@color/transparent</item>
<item name="android:centerDark">@color/transparent</item>
<item name="android:centerMedium">@color/transparent</item>
<item name="android:fullBright">@color/transparent</item>
<item name="android:fullDark">@color/transparent</item>
<item name="android:topBright">@color/transparent</item>
<item name="android:topDark">@color/transparent</item>
</style>

和增加值\ colors.xml

<color name="transparent">#00000000</color>

和设置 ProgressDialog 这样的:

 pd = new ProgressDialog(getActivity(),R.style.MyTheme);
 pd.setCancelable(false);
 pd.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
 pd.show();

这篇关于为什么ProgressDialog的背景不设置在透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆