An-droid
An-droid

Reputation: 6485

Android circular progress with transparent background

I have a fullscreen dialog that contain only a ProgressBar. The background of the dialog is transparent with the good color, but behind the progressbar, even if I set it's background to transparent there will an overlay...

How can I get this progressBar to have the same transparent background as the dialog ?

(I blanked private part informations)

enter image description here

Yes I used a custom view, but i tested with both default ProgressBar and the custom one, I get the same behavior.

I also tested with a DialogFragment, same result

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black_transparent"
    android:gravity="center"
    android:orientation="vertical">

    <com.wang.avi.AVLoadingIndicatorView
        android:id="@+id/progressBar"
        android:layout_width="@dimen/pop_button_height"
        android:layout_height="@dimen/pop_button_height"
        android:background="@color/black_transparent"
        android:visibility="visible"
        app:indicatorColor="@color/colorPrimaryDark"
        app:indicatorName="BallSpinFadeLoaderIndicator" />

</LinearLayout> 

Creation of the dialog in an Activity :

    mProgressDialog = new Dialog(this);
    View view = LayoutInflater.from(this).inflate(R.layout.dialog_loading_overlay, null);
    mProgressDialog.setCancelable(false);
    mProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mProgressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    mProgressDialog.setContentView(view);
    mProgressDialog.show();

Upvotes: 1

Views: 2187

Answers (1)

Bahu
Bahu

Reputation: 1596

Try this, it may works for you

mProgressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

Edit

Remove android:background="@color/black_transparent" in AVLoadingIndicatorView and try

Optional

If you want to put the background for that (If any warning came) use this android:background="@android:color/transparent"

Upvotes: 1

Related Questions