I use a custom view for an AlertDialog. In the emulator, there is some space above and below the customeView. If I set a title and buttons for the AlertDialog, I can see the gap between the title panel/button panel and the customView. How can I remove the gap?
My code to open the AlertDialog:
btnShowDialog.Click += (object sender, EventArgs e) =>
{
var customView = LayoutInflater.Inflate(Resource.Layout.myDialog, null);
var builder = new AlertDialog.Builder(this);
builder.SetTitle("Title");
builder.SetView(customView);
builder.Create().Show();
};
The customView layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<TextView
android:id="@+id/DialogText"
android:text="This is my custom view. Blur Blur Blur"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<EditText
android:id="@+id/EnterPhone"
android:inputType="phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:hint="enter your number" />
</LinearLayout>
I have tested the AlertDialog in android 4.0.3 and 4.1.2 emulator and get the same issue.
Thanks for help!
Instead of using
AlertDialog
try usingDialog
instead like so:This gives me the a dialog with no gap in the bottom.
You could also leave the title out and fill the entire
Dialog
with your custom view.And use this layout: