I want to remove the black background on custom dialog as shown in the picture. I\'m sure the black background was from the dialog, not from app\'s background.
you can create xml layout like following and set that layout on dialog(dialog.xml) :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" style="@style/white_background_bl_aatharv">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true" android:id="@+id/instructions_view">
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#FFFFFF"
android:text="text here " />
</LinearLayout>
</ScrollView>
here is the code to set layout on alert dialog :
AlertDialog alert = cndtnsbuilder.create();
alert.setView(LayoutInflater.from(
currentactivity.this).inflate(
R.layout.dialog, null));
alert.show();
To remove the background color, on layout, you just need to set the background to @null
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@null">
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Following method worked for me:
getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
//code style in style.xml :
<style name="translucentDialog" parent="android:Theme.Holo.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
</style>
// in activity :set style to dialog :
Dialog dialogconf = new Dialog(TreeAct.this, R.style.translucentDialog);
dialogconf.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialogconf.setContentView(R.layout.dialog_layout);
Just change Dialog parent them.
With black backround
<style name="MyDialog2" parent="@android:Theme.Dialog">
Without black background
<style name="MyDialog2" parent="@android:style/Theme.DeviceDefault.Light.Dialog">