所以我想绘制一个包含3列的网格,以便我可以:
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);
答案 0 :(得分:0)
我需要添加的是:
modelTitle.LayoutParameters = new TableRow.LayoutParams(0, LayoutParams.WrapContent, 1f);