iCaesar
iCaesar

Reputation: 411

android progress dialog background color

I'm trying to do my custom progress dialog with custom background. I find this example of custom progress dialog, but i need to change its background color from black to blue. I tryed to change this lines

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

in styles.xml from that example but it is not what i need...

What i do wrong ?

i tryed to change your xml in such way

<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>

but it have bottom line not filled with color baad

whats the problem now ?

i need such dialog

good

Upvotes: 1

Views: 4590

Answers (1)

Ankit
Ankit

Reputation: 483

Try this:

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

and main.xml like:

 <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>

please add custom_progress.xml into your drawable:

<?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>

Upvotes: 7

Related Questions