I am using a custom layout for the warning dialog in which I set a custom background image.
On display, it seems that the dialog box is larger than my background image, while I am setting the layout dimensions for the image sizes.
How do I set the size of a dialog box to the size of my background image? How to remove this white border?
thanks

Dialog window
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_root" android:orientation="vertical" android:background="@drawable/whip_sel_dialog_bg" android:layout_width="279dp" android:layout_height="130dp" > <TextView android:id="@+id/dialog_title" android:textColor="#FFF" android:textSize="16sp" android:textStyle="bold" android:text="@string/dialog_title" android:layout_width="fill_parent" android:gravity="center" android:layout_height="30dp" android:layout_marginTop="5dp"/> <TextView android:id="@+id/dialog_text" android:textColor="#FFF" android:layout_height="35dp" android:layout_width="fill_parent" android:gravity="center"/> <LinearLayout android:id="@+id/confirmation" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"> <Button android:id="@+id/button_cancel" android:layout_width="128dp" android:layout_height="43dp" android:background="@drawable/btn_ok" android:textColor="#FFF" android:text="@string/cancel" android:layout_marginRight="10dp"/> <Button android:id="@+id/button_ok" android:layout_width="128dp" android:layout_height="43dp" android:background="@drawable/btn_ok" android:textColor="#FFF" android:text="@string/ok" /> </LinearLayout> </LinearLayout>
dialog class
public class WSelDialog extends Dialog implements OnClickListener { private Button okButton, cancelButton; public WSelDialog() { super(MainActivity.this); setContentView(R.layout.whipem_dialog); okButton = (Button) findViewById(R.id.button_ok); okButton.setText(getString(R.string.whip_sel_ok)); okButton.setOnClickListener(this); cancelButton = (Button) findViewById(R.id.button_cancel); cancelButton.setText(getString(R.string.whip_sel_cancel)); cancelButton.setOnClickListener(this); TextView text = (TextView) findViewById(R.id.dialog_text); text.setText(getString(R.string.whip_sel)); text.setOnClickListener(this); } @Override public void onClick(View v) { ((GlobalVars)getApplicationContext()).playSound(100); if (v == cancelButton) dismiss(); else { Intent i = new Intent(MainActivity.this, WhipSelection.class); startActivity(i); } } };
source share