Reputation: 37464
I'm using a custom layout for an alert dialog, in which I set a custom background image.
When displayed, it seems that the dialog box is higher than my image background, while I set the layout dimensions to the image dimensions.
How can I set the dialog box dimensions to the dimensions of my background image? How can I remove this white border?
Thanks
dialog layout
<?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);
}
}
};
Upvotes: 4
Views: 2304
Reputation: 10211
It looks like the dialog reserves this space for its title. See Android: How to create a Dialog without a title.
Upvotes: 2