Wallflower Wallflower - 7 months ago 65
Java Question

Android custom dialog not fill the entire dialog layout

I build a custom dialog to pop up an image with close button like this:

result

As you can see the dialog is not fitting the dialog layout and there's this white borer on the top and on the right, so how can i get rid the white border thing and make my custom dialog fit?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:orientation="vertical" >

<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >

<LinearLayout
android:id="@+id/linearMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="-50dp" >
<ImageView
android:id="@+id/imgMain"
android:layout_width="300dp"
android:layout_height="350dp"
android:gravity="center"
android:background="@drawable/eairh_dialog"
/>

<!---add your views here-->
</LinearLayout>
<ImageView
android:id="@+id/imgClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:clickable="true"
android:src="@drawable/close_button" />
</FrameLayout>

</LinearLayout>

Answer
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

Use Above Code in your Dialog class to make Dialog TransParent

Comments