Search code examples
androidstylesprogress-bar

How to remove ProgressBar Background?


I have an app(Android 10+) in which I need to put a loading that disables user inputs.

As far as I coded, I found out I need to develop a ProgressBar

<ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyle"
        android:layout_width="48dp"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:indeterminate="true"
        android:indeterminateDrawable="@drawable/progress_indeterminate"/>

Everything is working fine, except that, when i run my app, that's what appears (for privacy reason, the black dot is the image of the animation, do not consider it)

enter image description here

What i'm trying to achieve here is to remove the blank background of the dialog, making it transparent. Is this possible? Do I have to conider a different Android layout?

Thanks


Solution

  • After some struggling, i found a way to resolve this case via Java code.

        alertDialog = builder.create();
        alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
        alertDialog.show();