I am trying to make the background from my dialog transparent. I want the progress bar to be shown in front of my activity. Unfortunately, the background stays always white.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@ id/loading_cont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:backgroundTint="#00000000"
android:background="@android:color/transparent"
>
<RelativeLayout
android:id="@ id/loading_dialog_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#00000000"
android:background="@android:color/transparent"
>
<ProgressBar
android:id="@ id/login_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true" >
</ProgressBar>
</RelativeLayout>
CodePudding user response:
Make a new Drawable Resource file
named transparent.xml
.
transparent.xml
<shape
android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
</shape>
Now set android:background="@drawable/transparent"
CodePudding user response:
Add this code where you are initializing your dialog
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
or you can also add this code instead
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));