【问题标题】:how to remove a background of custom progress dialog如何删除自定义进度对话框的背景
【发布时间】:2014-04-29 08:00:48
【问题描述】:

我正在制作自定义进度对话框

我的自定义样式代码是

 <style name="CustomDialog" parent="@android:style/Theme.Dialog">
 <item name="android:background">#000000</item>
 <item name="android:textColor">#FFFFFF</item>
 </style>

我的 java 代码是。

    pDialog = new ProgressDialog(context,R.style.CustomDialog);
    pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    pDialog.setMessage("Processing");

    pDialog.getWindow().setBackgroundDrawable(newColorDrawable(android.graphics.Color.TRANSPARENT));
    pDialog.setCancelable(false);
    pDialog.show();

现在我如何在我的进度对话框中删除背景颜色相同的是 图片链接是Using custom ProgressDialog android

【问题讨论】:

  • 您知道您链接的问题尚未得到解答。也许解决后你的答案会来自它?

标签: android


【解决方案1】:

在你的 style.xml 中:

<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsFloating">false</item>
    <item name="android:windowNoTitle">true</item>
</style>

在您的代码中:

pDialog = new ProgressDialog(context,R.style.CustomDialogTheme);

【讨论】:

  • 非常感谢,但现在进度对话框出现在顶部,我希望它出现在屏幕中间。
  • pDialog.getWindow().setGravity(Gravity.CENTER);
【解决方案2】:

按照你的风格使用它

<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>
</style>

感谢 SC 爵士

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-20
    • 1970-01-01
    • 2021-12-19
    相关资源
    最近更新 更多