0

In my app I have this situation: I open dialog and set the content view like this:

Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog);

dialog.xml

<?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="match_parent"
    android:background="@drawable/patientsbg"
    android:orientation="vertical" >
</LinearLayout>

And the result is this:

enter image description here

I want to have dialog exactly with my image and with no borders and spaces. Any idea ?

adneal
  • 30,484
  • 10
  • 122
  • 151
HK.avdalyan
  • 724
  • 1
  • 6
  • 21

1 Answers1

2

Just set your dialog background transparent as below:

Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog);
 dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

OR

Try to apply the theme to your dialog to remove the border of your dialog as below:

Create a style in your res/style and write below code in it.

<style name="Dialog_No_Border">
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowBackground">#00000000</item>
</style>

And set the above style in your dialog as below:

 dialog = new Dialog(this, R.style.Dialog_No_Border);
GrIsHu
  • 29,068
  • 10
  • 64
  • 102