I'm trying to display a dialog with a custom view. The Layout is pretty simple; basicly there are two LinearLayouts
; every Layout with a TextView
and an EditText
.
The Layout i'm using is this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_margin="5dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ll_element1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Element 1"/>
<EditText
android:layout_width="250dip"
android:layout_height="wrap_content"
android:lines="5"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_margin="5dip"
android:layout_width="wrap_content"
android:layout_below="@id/ll_element1"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Element 2"/>
<EditText
android:layout_width="250dip"
android:layout_height="wrap_content"
android:lines="5"/>
</LinearLayout>
</RelativeLayout>
But if i set it as view of a dialog the looks like this:
My Code to show the Dialog is this:
var view = this.LayoutInflater.Inflate(Resource.Layout.Custom_Dialog, null);
var dialog = new AlertDialog.Builder(this)
.SetView(view)
.Create();
dialog.Show();
In my opinion width of the Dialog should be smaller so that the Layout fills the dialog. I've tried several things:
- Using a LinearLayout instead of the RelativeLayout
- Setting all sizes explizit
- Used Dialog instead of AlertDialog
So, what do i have to do to get a correctly sized dialog?
edit Updated the Picture