protected virtual TextView GetHeaderText(string text, ActionSheetItemTextAlgin textAlgin) { var layout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, this.DpToPixels(56)) { LeftMargin = this.DpToPixels(16), RightMargin = this.DpToPixels(16), BottomMargin = this.DpToPixels(4), }; var txt = new TextView(this.Activity) { Text = text, LayoutParameters = layout, Gravity = GravityFlags.CenterVertical, }; txt.SetTextSize(ComplexUnitType.Sp, 16); txt.Paint.FakeBoldText = true; if (textAlgin == ActionSheetItemTextAlgin.Center) { txt.Gravity = GravityFlags.CenterVertical | GravityFlags.CenterHorizontal; } return(txt); }
protected View CreateRow(ActionSheetItem option, bool isDestructive, ActionSheetItemTextAlgin textAlgin) { var row = new LinearLayout(this.Activity) { Clickable = true, Orientation = Orientation.Horizontal, LayoutParameters = new LinearLayout.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, this.DpToPixels(48)) }; row.AddView(this.GetText(option.Text, option.ItemIcon, isDestructive, textAlgin)); row.Click += (sender, args) => { option.Action?.Invoke(); Clicked?.Invoke(); }; return(row); }
protected virtual TextView GetText(string text, string icon, bool isDestructive, ActionSheetItemTextAlgin textAlgin) { var layout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent) { TopMargin = this.DpToPixels(8), BottomMargin = this.DpToPixels(8), LeftMargin = this.DpToPixels(16), RightMargin = this.DpToPixels(16), }; var txt = new TextViewFix(this.Activity) { Text = text, LayoutParameters = layout, Gravity = GravityFlags.CenterVertical | GravityFlags.Left, }; txt.SetTextSize(ComplexUnitType.Sp, 16); // txt.SetBackgroundResource(global::Android.Resource.Attribute.SelectableItemBackground); if (!string.IsNullOrWhiteSpace(icon)) { var drawable = ImageLoader.Load(icon); drawable.SetBounds(0, 0, this.DpToPixels(32), this.DpToPixels(32)); txt.SetCompoundDrawables(drawable, null, null, null); txt.CompoundDrawablePadding = this.DpToPixels(6); txt.CenterText = textAlgin == ActionSheetItemTextAlgin.Center; } if (string.IsNullOrWhiteSpace(icon) && textAlgin == ActionSheetItemTextAlgin.Center) { txt.Gravity = GravityFlags.CenterHorizontal | GravityFlags.CenterVertical; } if (isDestructive) { txt.SetTextColor(Color.Red); } return(txt); }