Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Simple Custom Renderer of Searchbar - Android

$
0
0

I have a Searchar Control. On my Galaxy s4 it's with a grey background color. On the nexus it has a white background color.
Do I need a custom renderer?

For now I have:
public class StyledSearchbar : SearchBar { public Color farbe { get; set; } }

this simple searchbar:
StyledSearchbar searchBar = new StyledSearchbar { Placeholder = "Suche", Scale = 0.9, //HorizontalOptions = LayoutOptions.FillAndExpand, WidthRequest = 310, };

and my custom renderer:

[assembly: ExportRenderer(typeof(StyledSearchbar), typeof(StyledSearchBarRenderer))]

namespace ZF.Droid
{
    class StyledSearchBarRenderer : SearchBarRenderer {
        protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e)
        {
            base.OnElementChanged(e);
            var styledSearchbar = (StyledSearchbar)Element;
            styledSearchbar.BackgroundColor = Xamarin.Forms.Color.Red;
           }
    }   
    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>