So I am developing a Xamarin.Forms
application for Tablets, and now I need it to also run on phones - Great, Xamarin.Forms should handle all that (or so I thought).
I ran the application on my phone but it didnt scale down the Font (or any sizes for that matter, but I'll start with font)
I created an extension method like so:
[ContentProperty("FontSize")]
public class FontExtension : IMarkupExtension
{
public string FontSize { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
double fontSize;
if (FontSize == null)
throw new Exception("No Font Size provided");
if (!double.TryParse(FontSize, out fontSize))
throw new Exception("Font Size Provided is not a double");
return App.Scaling * fontSize;
}
}
and I use this in my application like FontSize={ns:Font 18}
and this will downscale my application based on the App.Scaling
property. This property is just set to 0.8
if it is a Phone
.
I also found two links that provided a way in Xamarin.Android
but I am doing a Xamarin.Forms
application so didnt apply. (link1,link2)
Is it possible to scale the font down based on the devices Resolution rather than Idiom?