Paradox Code
Paradox Code

Reputation: 148

Xamarin.Forms: SearchBar font size on windows phone

I have a problem with styling the SearchBar for Windows phone. The font size is just unbearably huge and there is not property I can set directly. I've read a bit upon custom renederers (though I believe that's just overkill if I jsut wanted to set font size imho) but I really don't know how to even begin and it's the only thing now that's holding me back from being able to deploy to Windows Phone. I tried searching for it but uncle Google sadly let me down on this one. Any help is of course greatly appreciated.

Screenshot:

Screenshot

Upvotes: 0

Views: 640

Answers (2)

Himanshu Dwivedi
Himanshu Dwivedi

Reputation: 8174

if you are using xaml then you can control style for different platforms like this:

<SearchBar x:Name="Search"
           Placeholder="Search"    
           TextChanged="SearchBar_OnTextChanged"  
           SearchButtonPressed="OnSearch" BackgroundColor="#19588F">
         <SearchBar.FontSize>
             <OnPlatform x:TypeArguments="x:Double"
                         WinPhone="10"
                         Android="22"
                         iOS="20" />
         </SearchBar.FontSize>
 </SearchBar>  

Upvotes: 1

Iv&#225;n Oliver
Iv&#225;n Oliver

Reputation: 126

Unfortunately, the documentation says it has no property to change the font size. So you do not have another option that implementarte a custom render for that control.

It could be that your cell had changed the size of the system font to a larger size?

Documentation: https://developer.xamarin.com/api/type/Xamarin.Forms.SearchBar/

Examples: https://forums.xamarin.com/discussion/27424/simple-custom-renderer-of-searchbar-android

Upvotes: 1

Related Questions