Matthias Vanb
Matthias Vanb

Reputation: 943

Dialog layout double layered wrong transparant background

I want to make a white, no bordered, popup view. To accomplish this I use a custom dialog with a custom style:

public Builder createNewDialog(int type) {
        AlertDialog.Builder dlg = null;
        switch (type) {
        case (1):

            dlg = new AlertDialog.Builder(new ContextThemeWrapper(this,
                    R.style.CustomDialogTheme));

            LayoutInflater inflater = this.getLayoutInflater();

            dlg.setView(inflater.inflate(R.layout.dialognewplayer, null))
                    .setPositiveButton("Add Player", null).setNegativeButton("Cancel", null).create();
            break;
        }
        return dlg;
    }

//styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="AppTheme" parent="android:Theme.Light"></style>
    <style name="CustomDialogTheme" parent="android:Theme.Dialog">
         <item name="android:windowBackground">@color/transparent_color</item>
        <item name="android:windowIsFloating">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:background">#ffffff</item>
    </style>

</resources>

//and colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
       <color name="transparent_color">#ffffff</color>
</resources>

However, as you can see at the image, the popup has some errors... it appears to be double layered with the first layer still having a border, and the transparant background is still black.. I think I am handling something wrong but I am not seeing it...

enter image description here

Upvotes: 2

Views: 1424

Answers (1)

Muhammad Aamir Ali
Muhammad Aamir Ali

Reputation: 21107

Use the Translucent Theme and use android own transparent color.

<style name="CustomDialogTheme" parent="@android:style/Theme.Translucent">
    <item name="android:windowIsFloating">false</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:background">@android:color/transparent</item>
</style>

Upvotes: 2

Related Questions