如何为手机和平板电脑开发 Xamarin 表单应用程序 [英] How to develop Xamarin forms app for Phone and Tablet

查看:55
本文介绍了如何为手机和平板电脑开发 Xamarin 表单应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1) 在 Android (Java) 中:
手机和平板电脑有不同的文件夹
布局
布局-大
布局-xlarge

1) in Android (Java) :
There are different folders for Phone and Tablet
Layout
Layout-large
layout-xlarge

2) 在 iOS 中:使用通用设置.

2) in iOS : use Universal setting.

我还没有尝试过 Xamarin 形式.我需要一些帮助.

I have not tried In Xamarin forms. I need some help.

如果该应用适用于手机和平板电脑,我需要做什么?并且有很多屏幕尺寸.

What are the things I need to do if the app is for Phone and tablet ? and there are so many screenSizes.

如何为多种屏幕尺寸设计页面?
如果我从平板尺寸开始,手机页面显示可能不合适?

How to design the Page for multiple screen sizes?
If I start from Tablet size, the page display in phone may be not fit?

推荐答案

Xamarin.Forms 使用称为AutoLayout"的东西,这意味着它使用约束系统来调整任何屏幕尺寸的内容,这就是为什么当您的设计您的应用时,您应该始终在多个设备上对其进行测试.

Xamarin.Forms uses something called 'AutoLayout' which means it uses a system of constraints in order to adjust the content for any screen size, which is why when your designing your app you should always test it on multiple devices.

Xamarin.Forms 使用 xaml 作为渲染显示的基本标记语言,并在运行时将其转换为本机对应物.对于 iOS,它转换为他们的统一 api,它使用自动布局来调整不同屏幕尺寸的视图.可在此处找到有关 xamarin 的 xaml 怪癖的信息.

Xamarin.Forms uses xaml as it's base markup language for renderng displays, and converts this into the native counterparts at runtime. for iOS it translates to their unified api which uses autolayout to resize views for different screen sizes. Information on xamarin's xaml quirks can be found here.

总而言之,使用 Xamarin.Forms 您不必太担心屏幕尺寸,它会根据您的布局和约束调整视图.所以每页有一个界面设计师,不需要多个故事板 (iOS) 或 android 替代品.

The long and short of it is that using Xamarin.Forms you don't have to worry too much about screen sizes, it will adjust the views based on your layout and constraints. So theres one interface designer per page, no need for multiple storyboards (iOS) or the android alternatives.

话虽如此,您仍然可以微管理您的视觉效果、设置动态字体大小、基于比例的动态大小控件或您想到的特定大小.老实说,我会从 Xamarin.Forms 示例应用程序之一开始,看看它们在不同设备上的工作情况.

That being said you can still micro manage your visuals, setting dynamic font sizes, dynamically sized controls based on ratios, or specific sizes that you have in mind. I would honestly start with one of the Xamarin.Forms sample applications to see them at work on different devices.

我们将 Xamarin.Forms 用于我们的跨平台应用程序之一,并且没有对我们在 Forms xaml 中使用的底层组件进行任何真正的调整,我可以肯定地说,它目前支持并适用于所有安卓平板电脑,所有苹果设备(Mac 系列除外),所有 Windows 设备(手机、平板电脑和台式电脑).所以我觉得你不用太担心.

We use Xamarin.Forms for one of our cross-platform applications and without any real adjustment to the underlying components we use in the Forms xaml, I can say with certainty that it currently supports and works on all android tablets, all apple devices (apart from their Mac family), all windows devices (Phones, tablets, and desktop pc's). So I don't think you should worry too much.

一些有用的链接:

平板电脑和桌面应用的布局. - 这里有一些关于 Xamarin.Forms 的更详细的信息.

Layout for Tablet and Desktop apps. - Heres some more detailed information on Xamarin.Forms.

主详细信息页面 - 非常适合专注于大型屏幕设备

Master Detail Pages - Ideal for focusing on just large screen devices

跨平台图片优化 - 你提到过这一点,关于 android 等的不同文件夹,情况仍然如此.

Cross-platform Image optimisation - You mentioned this, about different folders for android etc, that is still the case.

Xamarin.Forms 自适应 UI 解释 - 博客文章Xamarin.Forms 中的自适应 UI 的实际工作原理.

Xamarin.Forms Adaptive UI explained - Blog article about how adaptive UI in Xamarin.Forms actually works.

这篇关于如何为手机和平板电脑开发 Xamarin 表单应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆