0
我想更改AlertDialog的默認佈局大小。如何更改MvxDialogFragment佈局
我創建的類:
public class SampleDialog : MvxDialogFragment
{
public override Dialog OnCreateDialog(Bundle savedInstanceState)
{
var dialog = new AlertDialog.Builder(Context);
dialog.SetView(View.Inflate(Context,Resource.Layout.SampleDialog,null));
return dialog.Create();
}
public override void OnStart()
{
if (Dialog == null) { return; }
Dialog.Window.SetLayout(200,460);
base.OnStart();
}
}
,它的佈局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/text1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/text2" />
</LinearLayout>
而且我創建從片段視圖對話框:
var dialog = new SampleDialog
{
ViewModel = ViewModel,
Cancelable = true
};
dialog.Show(FragmentManager, "");
Tryed設置佈局寬度OnCreateDialog方法,OnStart,或直接通過設置LinearLayout.layout_width屬性,但結果是相同的。
這是怎麼配置的?