/// <summary> /// /// </summary> private void PrepareHint() { _hintLabel = new TextView(this.Context); _hintLabel.Text = "Hint label"; Android.Widget.RelativeLayout.LayoutParams relativeLayoutParameters = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); relativeLayoutParameters.AddRule(LayoutRules.AlignParentBottom); relativeLayoutParameters.AddRule(LayoutRules.CenterHorizontal); _hintLabel.LayoutParameters = relativeLayoutParameters; _hintLayout = new Android.Widget.RelativeLayout(this.Context); _hintLayout.LayoutParameters = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.MatchParent, 0); _hintLayout.SetPadding(0, 0, 0, 7); _hintLayout.AddView(_hintLabel); }
private Android.Views.View CreateLayout(Context context) { Android.Widget.RelativeLayout layout = new Android.Widget.RelativeLayout(context); var layoutParam = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); layout.SetPadding(30, 15, 30, 15); layout.LayoutParameters = layoutParam; //main layout Android.Widget.LinearLayout mainView = new Android.Widget.LinearLayout(context); var paramLayout = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); mainView.Orientation = Orientation.Vertical; paramLayout.AddRule(NativeCell.IsIncoming ? LayoutRules.AlignParentLeft : LayoutRules.AlignParentRight); paramLayout.SetMargins(NativeCell.IsIncoming ? 0 : 50, 0, NativeCell.IsIncoming ? 50 : 0, 0); mainView.SetPadding(30, 30, 30, 30); mainView.LayoutParameters = paramLayout; //set drawable GradientDrawable shape = new GradientDrawable(); shape.SetCornerRadius(NativeCell.CornerRadius * 2); shape.SetColor(NativeCell.IsIncoming ? NativeCell.IncomingColor.ToAndroid() : NativeCell.OutgoingColor.ToAndroid()); mainView.Background = shape; // name text NameText = new TextView(context); NameText.SetTextColor(NativeCell.NameFontColor.ToAndroid()); NameText.TextSize = NativeCell.NameFontSize; NameText.Text = NativeCell.Name; NameText.Id = Name_Text_Id; var paramNameText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); NameText.LayoutParameters = paramNameText; //message text MessageText = new TextView(context); MessageText.SetTextColor(NativeCell.TextFontColor.ToAndroid()); MessageText.Text = NativeCell.MessageBody; MessageText.TextSize = NativeCell.TextFontSize; MessageText.Id = Message_Text_Id; var paramMessageText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); MessageText.LayoutParameters = paramMessageText; // status layout LinearLayout linearLayout = new LinearLayout(context); linearLayout.Orientation = Orientation.Horizontal; var paramlinearLayout = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); paramlinearLayout.Gravity = Android.Views.GravityFlags.Right; linearLayout.SetGravity(Android.Views.GravityFlags.Right); linearLayout.LayoutParameters = paramlinearLayout; // status text StatusText = new TextView(context); StatusText.SetTextColor(NativeCell.InfoFontColor.ToAndroid()); StatusText.Text = StatusHelper.GetStatusString(NativeCell.Status); StatusText.Id = Status_Text_Id; StatusText.TextSize = NativeCell.InfoFontSize; StatusText.SetPadding(0, 0, 10, 0); StatusText.Gravity = Android.Views.GravityFlags.Left; var paramStatusText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); paramStatusText.Gravity = Android.Views.GravityFlags.Left; StatusText.LayoutParameters = paramStatusText; if (!NativeCell.IsIncoming) { linearLayout.AddView(StatusText); } // date text DateText = new TextView(context); DateText.SetTextColor(NativeCell.InfoFontColor.ToAndroid()); DateText.Text = NativeCell.Date; DateText.SetLines(1); DateText.TextSize = NativeCell.InfoFontSize; DateText.SetMinWidth(LayoutParams.WrapContent); DateText.Id = Date_Text_Id; var paramDateText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); DateText.LayoutParameters = paramDateText; linearLayout.AddView(DateText); if (!string.IsNullOrWhiteSpace(NameText.Text) && NativeCell.IsIncoming) { mainView.AddView(NameText); } mainView.AddView(MessageText); mainView.AddView(linearLayout); layout.AddView(mainView); return(layout); }