I need to remove the top and bottom padding of the built-in Entry, because I need the entry's height to be small. If there is too much padding, the text will not appear. So I implemented a custom entry with top and bottom padding set to 0. But it still looks like the built-in Entry. Text still does not appear. Only after I increase the Entry's height large enough, will the text appear.
Here is my custom renderer for Android:
[assembly: ExportRenderer(typeof(CustomEntry), typeof(CustomEntryRenderer))]
namespace MyApp.Droid.CustomControls
{
public class CustomEntryRenderer : EntryRenderer
{
public CustomEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (e.NewElement == null)
{
return;
}
if (this.Element is CustomEntry customEntry)
{
var paddingLeft = (int)customEntry.Padding.Left;
var paddingRight = (int)customEntry.Padding.Right;
this.Control.SetPadding(paddingLeft, 0, paddingRight, 0);
}
}
}
}
