Android 仅使用微调器(在中间)创建一个 progressDialog
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21751662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create a progressDialog only with the spinner (in the middle)
提问by Filnik
I need to create a progressDialog only with the spinner and without the box (or at least with a smaller box and the image in the middle).
我只需要使用微调器而不使用框(或至少使用较小的框和中间的图像)创建一个 progressDialog 。
I don't want to add a spinner to my .xml (layout file) to load the spinner.
我不想在我的 .xml(布局文件)中添加微调器来加载微调器。
Is there any way to accomplish this? Thanks!
有什么办法可以做到这一点吗?谢谢!
回答by M D
try this way:
试试这个方法:
pd = new ProgressDialog(Login.this,R.style.MyTheme);
pd.setCancelable(false);
pd.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
pd.show();
And create Themein values\styles.xml
并在其中创建主题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>
And also add this Themein values\styles.xml
并将此主题添加到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>
And add values\colors.xml
并添加 values\colors.xml
<color name="transparent">#00000000</color>
回答by SANAT
Just single line code :
只是单行代码:
pd.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));