android进度对话框背景颜色

标签 android background styles progressdialog

我正在尝试使用自定义背景进行自定义进度对话框。我找到 this自定义进度对话框的示例,但我需要将其背景颜色从黑色更改为蓝色。 我试图改变这一行

<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:background">@android:color/transparent</item>

在那个例子的 styles.xml 中,但这不是我需要的...

我做错了什么?

我试图以这种方式更改您的 xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#3300CC"
    tools:context=".MainActivity" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:background="#3300CC"
        android:orientation="horizontal" >

        <ProgressBar
            android:id="@+id/progressBar1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </RelativeLayout>

</RelativeLayout>

但是底线没有填充颜色baad

现在有什么问题?

我需要这样的对话框

good

最佳答案

试试这个:

    ProgressDialog mProgressDialog = ProgressDialog.show(MainActivity.this, "", "");
    mProgressDialog.setContentView(R.layout.main);
    mProgressDialog.show();

和 main.xml 类似:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity" >

        <RelativeLayout
            android:layout_width="135dp"
            android:layout_height="56dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="146dp"
            android:background="#3300CC"
            android:orientation="horizontal" >

            <ProgressBar
                android:id="@+id/progressBar1"
                android:layout_width="wrap_content"
                android:indeterminateDrawable="@drawable/custom_progress"
                android:max="10000"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_toRightOf="@+id/progressBar1"
                android:text="Please wait..." />
        </RelativeLayout>

    </RelativeLayout>

请将 custom_progress.xml 添加到您的可绘制对象中:

<?xml version="1.0" encoding="utf-8"?>
<rotate 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:pivotX="50%" 
    android:pivotY="50%" 
    android:fromDegrees="0"
    android:toDegrees="1080">

    <shape android:shape="ring" 
        android:innerRadiusRatio="5"
        android:thicknessRatio="20" 
        android:useLevel="false">



        <gradient 
            android:type="sweep" 
            android:useLevel="false"
            android:startColor="#FFFFFF" 
            android:centerColor="#FFFFFF"
            android:centerY="0.50" 
            android:endColor="#0D8FDB" />
    </shape>

</rotate>

关于android进度对话框背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21499935/

相关文章:

android - 我是否应该担心内存泄漏以及在 Android 中将 WeakReference 与 Volley 结合使用

wpf - 如何进行Wpf TabItem样式HeaderTemplate绑定(bind)?

java - 如何继承Android样式属性?

javascript - Safari 在后台选项卡中延迟 setInterval/setTimeout (interval > 1000ms)

actionscript-3 - Flex - 在后台运行空气应用程序

css 文本阴影

android - 设计 View 中的无尽 "Loading Configuration"

android - 在 Android 中使用 Firebase 时出现内存不足错误

android - 如何理解Android Studio中的内存分配?

time - 根据时间改变背景 - Objective C