中提供多设备支持

中提供多设备支持

本文介绍了如何在 Xamarin Forms 中提供多设备支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Xamarin 开发的新手.

在 android 中,我们有不同的值文件夹用于多设备支持.

但在 Xamarin 形式中,我们如何为 Android 和 Android 提供多设备支持iOS?

任何人都不知道什么是多设备支持请查看 Android 的示例文档

I am newbie to Xamarin development.

In android we have different values folder for multi-device support.

But In Xamarin forms how we give multi-device support for Android & iOS?

Anyone don't know about what is multi-device support pls check the sample document by Android
https://developer.android.com/guide/practices/screens_support.html

I want similar like this for Xamarin forms.

Note: I am asking about Xamarin forms not in native code.

Any suggestions or ideas are welcome. Thanks for your answers.

解决方案

Xamarin.Forms XAML Support :

Xamarin.Forms use the platform-specific mechanisms to calculate the absolute pixel dimensions. As Digitalsa1nt said, Xamarin.Forms uses xaml as it's base markup language for renderng displays, and converts this into the native counterparts at runtime. Usually, you don't have to care about the resolution, it will adjust the views based on your layout and constraints.


Some useful link about Xamarin.Forms multi-device support :


Update :

You could read this official document: Dealing with sizes and the related sample. It demonstrates many solutions to solve your problem :

For example : the Platform-specific font size at no cost

In some cases we need to assign a different font size to controls based on the specific operating system's styles, avoiding hard-coded values. Through the Device class, Xamarin.Forms makes this possible at no cost.

In your Page OnAppearing() method :

protected override void OnAppearing()
{
    base.OnAppearing();
    this.LargeLabel.FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));
    this.SmallLabel.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
    this.MediumLabel.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
}

Effect :

这篇关于如何在 Xamarin Forms 中提供多设备支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 02:49