Hello,
Welcome to our Microsoft Q&A platform!
You can set the this.Control.SetBackground(null);
in the custom renderer.
============
Update================
You can try to set the TextVariationVisiblePassword
for custom renderer of Entry.
this.Control.InputType=InputTypes.TextVariationVisiblePassword;
================
Update2==================
I also need this custom entry for a password. Can I add like a condition to check if the enry is a password?
Do you want to add property like following code?
public class CustomEntry : Entry
{
public static readonly BindableProperty IsPasswordFlagProperty =
BindableProperty.Create("IsPasswordFlag", typeof(bool), typeof(CustomEntry), defaultBindingMode: BindingMode.OneWay);
public bool IsPasswordFlag
{
get { return (bool)GetValue(IsPasswordFlagProperty); }
set { SetValue(IsPasswordFlagProperty, value); }
}
}
Then Entry's custom renderer, you can judge it.
[assembly: ExportRenderer(typeof(CustomEntry), typeof(CustomEntryRendererAndroid))]
namespace RefreshViewDemo.Droid
{
public class CustomEntryRendererAndroid : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
GradientDrawable gd = new GradientDrawable();
gd.SetColor(Android.Graphics.Color.Transparent);
this.Control.SetBackground(gd);
this.Control.SetPadding(20, 0, 0, 0);
CustomEntry customEntry= (CustomEntry) e.NewElement ;
if (customEntry.IsPasswordFlag)
{
this.Control.InputType = InputTypes.TextVariationVisiblePassword;
}
}
}
public CustomEntryRendererAndroid(Context context) : base(context)
{
}
}
In the end, use it in xamarin,forms.
<local:CustomEntry IsPasswordFlag="True"></local:CustomEntry>
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.