【问题标题】:Android, Change progress dialog background color?Android,更改进度对话框背景颜色?
【发布时间】:2015-11-25 16:47:56
【问题描述】:

我有一个完全由 java 代码定义的进度对话框。我只想更改背景颜色和可能的文本颜色。我在 stackoverflow 中看到过其他帖子,例如添加 style.xml 等,但没有一个有效。请不要让我参考其他帖子。该怎么办? 我的代码听起来像这样:

 Class A extends Activity {
   ProgressDialog pd;
   Context context;
   public void onCreate(){
   context = A.this;
   pd = new ProgressDialog.show(context, "" , "Loading");
   }
 }

![A sample of progress dialog which i want. Actually i have it , but the problem is the background color which i want to be white.]1

【问题讨论】:

  • 默认颜色是白色吗?
  • 不,是黑色的。其实我想把它改成白色。
  • 您是否在 style.xml 中使用了 android:alertDialogStyle 项?
  • 阅读我给 Eric B 留下的评论。谢谢。

标签: android progressdialog


【解决方案1】:
pd = new ProgressDialog.show(context, "" , "Loading");
pd.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.RED));

【讨论】:

    【解决方案2】:

    在您的代码中执行此操作:

    Class A extends Activity {
       ProgressDialog pd;
       Context context;
       public void onCreate(){
       context = A.this;
       pd = new ProgressDialog(context, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert);
       pd.setTitle("");
       pd.setMessage("Loading");
       pd.show();
       }
     }
    

    【讨论】:

    • 我之前使用过 style.xml 并设法更改了 pd,但结果不是我所期望的。我只需要一个简单的白色 pd,里面有一个圆圈。就像向下滚动关注者或媒体列表时的 Instagram 应用程序或...。每个 style.xml 都需要一个不符合我的情况的父主题。
    • “结果不是我所期望的” 当你这样做时,pd 怎么样?能否请您从 instagram 发布图片,以便我了解一下。
    • 我上传了我想要的屏幕截图。
    • 这不是一个进度对话框。这更像是一个进度条,一个不确定的。你可以控制它的可见性,让它消失或可见。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-07
    • 2013-12-29
    • 1970-01-01
    • 2017-05-24
    • 2013-08-23
    相关资源
    最近更新 更多