I have a custom AlertDialog and I want to make it's background completely transparent. Normally to make an activity completely transparent, I do the following
set background to
#00000000
in the xml layoutin the manifest set
android:theme="@android:style/Theme.Holo.Dialog"
for the activity.In onCreate add
getWindow().setBackgroundDrawable(new ColorDrawable(0))
.But now that I am dealing with a Dialog, how do I accomplish transparency?
Here is the 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();
And my xml is just a relativeLayout with other child views:
<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>
Note: I have already looked at some similar posts here, but they don't seem to work.
My real reason is that the background that I really want to use, is not rectangular. I get it to work in an activity. But I want to use a dialog instead.
EDIT:
Further playing around, I have this 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>
Which I add as
new AlertDialog.Builder(this, R.style.CustomDialog)