1
votes

I have used custom rendering to display the entry cell in xamarin forms for IOS and android. I am able to change the background color of the cell but is there any way to set any background image to an entry cell. Also how to hide the under bar line in android entry cell which comes default.

My custom entry cell in PCl :

<local:MyEntry Placeholder="Placeholder" PlaceholderColor="Grey" TextColor="Black"/>
1

1 Answers

3
votes

Yes, you can set any background image to an entry cell.

For IOS you need to do this:

Control.BorderStyle = UITextBorderStyle.None;
UIImage img = UIImage.FromFile("ImageName.png");
Control.Background = img;

For android :

Control.Background = ContextCompat.GetDrawable(Context, Resource.Drawable.ImageName);

In order to hide the underbar in android use this:

Control.SetBackgroundColor(global::Android.Graphics.Color.Transparent);

After doing this you can adjust the height width of background image of entry cell from xaml like this:

 <local:MyEntry Placeholder="placeholder" PlaceholderColor="Grey" TextColor="Black" WidthRequest="200" HeightRequest="50"/>