支持多种屏幕尺寸 - 机器人机器人、多种、屏幕尺寸

2023-09-12 00:37:59 作者:╭ァ忘bū掉の傷

我要开发的Andr​​oid新应用程序。此应用程序应该只肖像(甚至片)工作的研究。另外,用户界面​​和布局设计应该是在手机和平​​板电脑类似。我们无法改变的布局设计,平板电脑,因为它有巨大的地区使用。我们必须弹力,以配合手机的图像。我们可以用9补丁。但我有点困惑使用图像的多个可绘制的。

I am going to develop new application in Android. This application should only work in portrait (even for tablet). Also the UI and layout design should be similar on phones and tablet. We can't change the layout design for tablet as it has huge area to use. We have to stretch all the images to match phones. We can use nine patch. But I am little bit confused of using images in multiple drawables.

按我的分析(可能是错误..:))将屏幕分成密度和大小。我们可以使用的3缩放比率:4:6:8。但这个比例是基于密度。但是,在我的情况下,我不得不伸展整个UI,填补了平板电脑屏幕。

As per my analysis (may be wrong.. : ) ) the screens are divided into density and sizes. We can use the scaling ratio of 3:4:6:8. But this ratio is based on the density. But in my case I have to stretch the entire UI to fill the Tablet screen.

那么什么是可用于这样的应用程序,其可以支持多个设备的可绘制。什么是屏幕尺寸,我们必须设计。

So what are the drawables that can be used for a app like this which can support multiple devices. And what are the screen sizes for which we have to design.

和这个应用程序需要近100布局。所以,我打算保持单一的布局和设计使用重量为每个布局,而不是使用方面的布局。

And this application needs nearly 100 layouts. So I am planning to maintain single layout and designing the layout using weight for each layout instead of using dimension.

另外,如果我用多个APK来支持不同的屏幕尺寸都有哪些可绘制用于支持  1.小和正常  2.大  3. XLARGE

Also if I used multiple APKs to support different screen size what are the drawables used to support 1. Small and Normal 2. Large 3. Xlarge

推荐答案

我只是做了一件很相似。舒展的应用程序,而无需创建新的布局我用XML设置尺寸

I just did something very similar. To stretch the app without creating new layouts I used dimensions set in XML

res/values/dimensions.xml
res/values-sw600dp/dimensions.xml -> 7+ inches
res/values-sw720dp/dimensions.xml -> 10+ inches

尺寸为资源文件:

Dimensions are resources files:

<dimen name="default_padding">11dp</dimen>

您可以30%左右,在600和720的文件增加尺寸。 然后,只需使用你的布局 @扪/ default_padding ,这将被调整

You can increase the dimensions by about 30% in the 600 and 720 file. Then simply used @dimen/default_padding in your layout and it will be scaled

对于图像,无论是你要确保你把所有的资产都密度,或者你设置固定的大小为您的ImageView 的和适当的 scaleType

Regarding images, either you make sure you have all your assets in all densities, or you set fixed size to you ImageView's and appropriate scaleType