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属性,但结果是相同的。
这是怎么配置的?