public TextEntry(Context context, string title, bool isRequired = false) : base(context, title, isRequired) { Field = new EditText(context); Field.TextSize = 14.0f; Field.SetTextColor(Color.DarkGray); Field.SetBackground(Color.White); Field.ImeOptions = ImeAction.Done; Field.InputType = Android.Text.InputTypes.TextFlagImeMultiLine; Field.SetBackground(Color.White); Field.SetBorderColor((int)(1 * Density), Colors.CartoNavy); AddView(Field); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control != null) { EditText nativeEditText = (EditText)Control; ShapeDrawable shape = new ShapeDrawable(new Android.Graphics.Drawables.Shapes.RectShape()); shape.Paint.Color = Xamarin.Forms.Color.Black.ToAndroid(); shape.Paint.SetStyle(Paint.Style.Stroke); nativeEditText.Background = shape; GradientDrawable gd = new GradientDrawable(); gd.SetColor(Android.Graphics.Color.Rgb(247, 246, 246)); gd.SetCornerRadius(50f); gd.SetStroke(0, Android.Graphics.Color.LightGray); nativeEditText.SetBackground(gd); Control.SetPadding(40, 40, 40, 40); } }
protected void UpdateBackground(EditText control) { if (control == null) { return; } var gd = new GradientDrawable(); gd.SetColor(Element.BackgroundColor.ToAndroid()); gd.SetCornerRadius(Context.ToPixels(ElementV2.CornerRadius)); gd.SetStroke((int)Context.ToPixels(ElementV2.BorderThickness), ElementV2.BorderColor.ToAndroid()); control.SetBackground(gd); var padTop = (int)Context.ToPixels(ElementV2.Padding.Top); var padBottom = (int)Context.ToPixels(ElementV2.Padding.Bottom); var padLeft = (int)Context.ToPixels(ElementV2.Padding.Left); var padRight = (int)Context.ToPixels(ElementV2.Padding.Right); control.SetPadding(padLeft, padTop, padRight, padBottom); }