我如何绘制一个网格与3列,其中2列大小的内容
本文关键字:2列 其中 3列 网格 何绘制 绘制 一个 | 更新日期: 2023-09-27 18:16:21
我想画一个三列的网格这样我就可以有:
Cancel Title Save
但此刻我得到
Cancel Title Save
我的代码是:
var modalContentPage = sender as ModalContentPage;
var context = Android.App.Application.Context;
var actionBar = ((Activity)Context).ActionBar;
LinearLayout gridView = new LinearLayout(context);
gridView.SetGravity(GravityFlags.FillHorizontal|GravityFlags.CenterVertical);
LinearLayout.LayoutParams textViewParameters =
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
Android.Widget.Button cancelButton = new Android.Widget.Button(context);
cancelButton.Text = "Cancel";
cancelButton.Click += delegate
{
modalContentPage.CancelCommand.Execute(null);
};
gridView.AddView(cancelButton, LayoutParams.WrapContent);
TextView modelTitle = new TextView(context);
modelTitle.Text = actionBar.Title;
modelTitle.TextFormatted = actionBar.TitleFormatted;
modelTitle.Gravity = GravityFlags.Center;
modelTitle.TextSize = 25;
modelTitle.SetTypeface(Android.Graphics.Typeface.Default, Android.Graphics.TypefaceStyle.Bold);
modelTitle.SetTextColor(Android.Graphics.Color.White);
gridView.AddView(modelTitle);
Android.Widget.Button saveButton = new Android.Widget.Button(context);
saveButton.Text = "Save";
saveButton.Click += delegate
{
modalContentPage.SaveCommand.Execute(null);
};
saveButton.Background.SetColorFilter((Resources.GetColor(Resource.Color.accent)),Android.Graphics.PorterDuff.Mode.Multiply);
saveButton.Gravity = GravityFlags.Center;
gridView.AddView(saveButton,LayoutParams.WrapContent);
ActionBar.LayoutParams actionbarParams =
new ActionBar.LayoutParams(ActionBar.LayoutParams.MatchParent, ActionBar.LayoutParams.MatchParent);
actionBar.SetCustomView(gridView, actionbarParams);
actionBar.SetDisplayShowCustomEnabled(true);
actionBar.SetIcon(new ColorDrawable(Color.Transparent.ToAndroid()));
actionBar.SetDisplayHomeAsUpEnabled(false);
我只需要添加:
modelTitle.LayoutParameters = new TableRow.LayoutParams(0, LayoutParams.WrapContent, 1f);