如何在 Android 中设计任何屏幕尺寸和密度(Android 中的手机多屏)

编程入门 行业动态 更新时间:2024-10-24 01:51:08
本文介绍了如何在 Android 中设计任何屏幕尺寸和密度(Android 中的手机多屏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何在不使用值文件夹中的维度的情况下处理 Android 手机的多屏设计.

我的应用程序支持所有安卓手机,但我的设计有问题,因为我在 values 文件夹中使用 dimen 来处理它.

所以请任何人都可以帮助我在不使用维度的情况下处理这个问题.

解决方案

布局兼容性对于任何项目都是非常重要的部分

抱歉,您必须使用尺寸来处理此问题.我认为最好的设计方式是使用密度.

您可以使用 dimens-hdpi 或 dimens-mdpi 或 ...

并且可以使用 dimens-small 或 dimens-large 或 ...

并且可以同时使用它们.如dimens-larg-mdpi

但这很难设计.

我使用尺寸最小的屏幕宽度这种使用密度,我认为您可以通过 4 或 5 个维度处理所有手机或平板电脑.

喜欢这张图片.

屏幕宽度 dp 的典型数字是:

  • 320:手机屏幕(240x320 ldpi、320x480 mdpi、480x800 hdpi 等).
  • 480:像 Streak 一样的 tweener 平板电脑 (480x800 mdpi).
  • 600:7 英寸平板电脑 (600x1024).
  • 720:10 英寸平板电脑(720x1280、800x1280 等).
  • 如果您的设备不支持其中之一,您可以添加另一个最小的屏幕宽度.

您可以在

  • 第一个公式可帮助您计算每英寸像素数 (dpi).
  • 第二个公式可帮助您计算像素比率.
  • 最后一个公式可帮助您计算 dp.

这款手机的宽度为 392 dp,最小宽度为 320.

如果您喜欢使用 dpi 像素比 可以帮到你.

  • ldpi => 像素比 = 0.75
  • mdpi => 像素比 = 1.0
  • hdpi => 像素比 = 1.5
  • xhdpi => 像素比 = 2
  • xxhdpi => 像素比 = 3
  • xxxhdpi => 像素比 = 4

How to handle design in multi screen for mobiles in Android without using dimention in values folder.

My application it's support all android mobiles, and I had a problem with the design, because I'm using dimen in values folder to handle it.

So please anyone can help me to handle this problem without using the dimention.

解决方案

layout compatibility is very important part of any project

sorry but you have to use dimens for handle this problem. and i think best way for design is use density.

you can use dimens-hdpi or dimens-mdpi or ...

and can use dimens-small or dimens-large or ...

and can use both of them together. like dimens-larg-mdpi

but this is so hard to design.

i using dimens smallest screen width this use density and i think you can handle all of phones or tablets by 4 or 5 dimens.

like this picture.

Typical numbers for screen width dp are:

  • 320: a phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
  • 480: a tweener tablet like the Streak (480x800 mdpi).
  • 600: a 7" tablet (600x1024).
  • 720: a 10" tablet (720x1280, 800x1280, etc).
  • if you have a device don't support by one of these you can add another smallest screen width for that.

you can read more details here , here , here and this help you know your phone pixels per inch.

example:

you have a phone 1080*1920 pixel and 5" size.

  • first formula help you calculate pixel per inch (dpi).
  • second formula help you calculate Pixel ratio.
  • and last formula help you calculate dp.

this phone have 392 dp in width and smallest width for that is 320.

if you like use dpi Pixel ratio can help you.

  • ldpi => Pixel ratio = 0.75
  • mdpi => Pixel ratio = 1.0
  • hdpi => Pixel ratio = 1.5
  • xhdpi => Pixel ratio = 2
  • xxhdpi => Pixel ratio = 3
  • xxxhdpi => Pixel ratio = 4

更多推荐

如何在 Android 中设计任何屏幕尺寸和密度(Android 中的手机多屏)

本文发布于:2023-11-28 06:42:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641338.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密度   如何在   屏幕尺寸   多屏   手机

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!