【问题标题】:android progress dialog background colorandroid进度对话框背景颜色
【发布时间】:2014-02-01 15:28:56
【问题描述】:

我正在尝试使用自定义背景进行自定义进度对话框。我找到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>

但它的底线没有填充颜色

现在有什么问题?

我需要这样的对话

【问题讨论】:

    标签: android background styles progressdialog


    【解决方案1】:

    试试这个:

        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>
    

    【讨论】:

    • 谢谢回答,我试过但没有任何改变,我更新了我的第一篇文章,请看
    • 我已经更新了代码.. 将 custom_progress.xml 添加到您的drawable中,并将 android:indeterminateDrawable="@drawable/custom_progress" android:max="10000" 添加到您的progressdialog中..
    • @Kimmi-这不是与自定义进度对话框相关的问题。它与您的代码有关。请使用检查 mprogressdialog != null && mprogressdialog.isShowing() 进行异常处理..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多