android AlertDialog mit transparentem hintergrund

Habe ich eine benutzerdefinierte AlertDialog und ich es machen will, ist der hintergrund vollkommen transparent.
Normalerweise, um eine Aktivität, die völlig transparent ist, mache ich die folgenden

  • hintergrund zu #00000000 im xml-layout

  • in der manifest-set android:theme="@android:style/Theme.Holo.Dialog" für die Aktivität.

  • In onCreate hinzufügen getWindow().setBackgroundDrawable(new ColorDrawable(0)).

    Aber jetzt, dass ich es mit einem Dialog, wie kann ich erreichen, Transparenz?

Hier ist der dialog-code:

LayoutInflater inflater = getLayoutInflater();
    View dialoglayout = inflater.inflate(R.layout.activity_mine1,
        (ViewGroup) findViewById(R.layout.mine1));
    mine1 = new AlertDialog.Builder(this);
    mine1.setView(dialoglayout);
    mine1.show();

Und meine xml ist nur ein relativeLayout mit anderen untergeordneten Ansichten:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#00000000" >

    ...

</RelativeLayout>

Hinweis: ich sah schon einige ähnliche Beiträge hier, aber Sie scheinen nicht zu funktionieren.

Meine wirkliche Grund ist, dass der hintergrund, dass ich wirklich wollen, um zu verwenden, ist nicht rechteckig. Ich bekomme es auf der Arbeit in einer Tätigkeit. Aber ich möchte an einem dialog statt.

EDIT:

Weiter zu spielen, habe ich diese style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="CustomDialog" parent="android:Theme.Holo.Dialog">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
    </style>
</resources>

Welche ich hinzufügen, wie

new AlertDialog.Builder(this, R.style.CustomDialog)
  • attr dialogBackground wird nicht erkannt von eclipse.
InformationsquelleAutor Cote Mounyo | 2013-07-10
Schreibe einen Kommentar