So I am working on Android application. Right now I am creating MainPage where I insert Entry
which has the bottom line as always. The bottom line on my previewer is White
while on my phone it appears to be Black
.
So to fix the issue I decided to play with renderers and see if I can fix it.
I created Class in App called CustomEntryRenderer
which inherits from Entry.
Then I created Class in App.Android called CustomEntryRednererAndroid
which is supposed to change the color of bottom entry line. But it doesn`t affect it. I tried doing the same with some custom renderers I found on the internet.
For example deleting bottom line didn`t affect the program as well: removing line
Entry from MainPage.xaml:
<Entry
Grid.Row="4"
Grid.ColumnSpan="2"
TextColor="Silver"
Placeholder="Write Your nickname"
PlaceholderColor="Silver"
/>
CustomEntryRenderer:
public class CustomEntryRenderer : Entry
{
}
CustomEntryRendererAndroid:
[assembly: ExportRenderer(typeof(CustomEntryRenderer), typeof(MyEntryRenderer))]
namespace App3.Droid
{
public class MyEntryRenderer : EntryRenderer
{
public MyEntryRenderer(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control == null || e.NewElement == null) return;
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
Control.BackgroundTintList = ColorStateList.ValueOf(Android.Graphics.Color.White);
else
Control.Background.SetColorFilter(Android.Graphics.Color.White, PorterDuff.Mode.SrcAtop);
}
}
}
Top answer for Android
And for some reason also in CustomEntryRendererAndroid.cs
I had to use Android.Graphic
instead of Xamarin.Forms.Color
. But I dont think that is the issue.
I have been trying for a couple of hours now and can`t find the way out of this situation. Would appreciate any ideas.