private void UpdatePadding(CualevaRoundedEntry entryEx) { int paddingToAdd = 0; Control.SetPadding((int)Forms.Context.ToPixels(entryEx.LeftPadding + paddingToAdd), 0, (int)Forms.Context.ToPixels(entryEx.RightPadding), 0); }
private void UpdateTextAlighnment(CualevaRoundedEntry entryEx) { var gravity = DefaultGravity; switch (entryEx.HorizontalTextAlignment) { case Xamarin.Forms.TextAlignment.Start: gravity |= GravityFlags.Start; break; case Xamarin.Forms.TextAlignment.Center: gravity |= GravityFlags.CenterHorizontal; break; case Xamarin.Forms.TextAlignment.End: gravity |= GravityFlags.End; break; } Control.Gravity = gravity; }
private void UpdateBackground(CualevaRoundedEntry entryEx) { var gradientDrawable = new GradientDrawable(); gradientDrawable.SetCornerRadius(entryEx.BorderRadius); gradientDrawable.SetStroke((int)entryEx.BorderWidth, entryEx.BorderColor.ToAndroid()); gradientDrawable.SetColor(entryEx.CualevaRoundedEntryBackgroundColor.ToAndroid()); if (!string.IsNullOrWhiteSpace(entryEx.Image)) { List <Drawable> layers = new List <Drawable>(); layers.Add(gradientDrawable); LayerDrawable layerDrawable = new LayerDrawable(layers.ToArray()); layerDrawable.SetLayerInset(0, 0, 0, 0, 0); Control.SetBackground(layerDrawable); } else { Control.SetBackground(gradientDrawable); } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement != null || this.Element == null) { return; } Control.Gravity = DefaultGravity; var entryEx = Element as CualevaRoundedEntry; ELEMENT = Element as CualevaRoundedEntry; UpdateBackground(entryEx); UpdatePadding(entryEx); UpdateTextAlighnment(entryEx); var editText = this.Control; editText.SetSelectAllOnFocus(true); if (!string.IsNullOrEmpty(entryEx.Image)) { editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(entryEx.Image), null, null, null); } editText.CompoundDrawablePadding = 25; }