1

I have a ConstraintLayout that i'm using as a popup in my app and i want this popup to be translucid.

I have tried with colors like #33000000, which should be a translucid black, but it shows like a light gray. If i set my background color to "@android:color/transparent" and it changes to white, so i think the issue is that i have like a default white background.

Also when i set round corners i see that white background behind my ConstrinatLayout with the rounded corners.

This is my ConstraintLayout code. I have a couple TextViews and an image inside.

<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="350dp"
android:layout_height="475dp"
android:background="#33000000"
android:padding="10dp"
android:layout_gravity="center">

Please let me know if more code or details are needed.

The following screenshot is with radius=50dp and backgroundcolor=#B3808080.

PopUp ScreenShot

  • If you are using a `Dialog` you should look at https://stackoverflow.com/questions/10795078/dialog-with-transparent-background-in-android – GSala Mar 29 '20 at 10:43

1 Answers1

0

set WindowdisablePreview in style.xml under Base theme tag

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>

        <item name="android:windowDisablePreview">true</item>

    </style>

and then in dialog method set background transparent

 dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
AndroWaqar
  • 231
  • 2
  • 9