gpt4 book ai didi

android - 在 android 中使用的最佳限定符是什么?

转载 作者:行者123 更新时间:2023-11-30 00:07:46 27 4
gpt4 key购买 nike

Android 可在提供不同屏幕尺寸和密度的各种设备上运行。对于应用程序,Android 系统提供跨设备一致的开发环境,并处理大部分工作,将每个应用程序的用户界面调整到显示它的屏幕。同时,系统提供 API 允许您针对特定的屏幕尺寸和密度控制您的应用程序的 UI,以便针对不同的屏幕配置优化您的 UI 设计。例如,您可能想要一个不同于手机 UI 的平板电脑 UI。

这让我们想到了这个问题,从下面的列表中可以使用什么是最好的限定符:

A set of six generalized densities:
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi

或者

sw600dp
sw720dp
w720dp
w1024dp
h720dp
h1024dp

一组屏幕尺寸:

 small  
normal
large
xlarge

最佳答案

我建议使用

sw600dp
sw720dp
w720dp
w1024dp
h720dp
h1024dp

因为有了这些,您可以精确地控制它的外观,同时让您更容易快速判断值。

此外,这是更“现代”的尺寸定义方式。

来自 developer.android.com :

One of the difficulties developers had in pre-3.2 Android devices was the "large" screen size bin, which encompasses the Dell Streak, the original Galaxy Tab, and 7" tablets in general. However, many applications may want to show different layouts for different devices in this category (such as for 5" and 7" devices), even though they are all considered to be "large" screens. That's why Android introduced the "Smallest-width" qualifier (amongst others) in Android 3.2.

The Smallest-width qualifier allows you to target screens that have a certain minimum width given in dp. For example, the typical 7" tablet has a minimum width of 600 dp, so if you want your UI to have two panes on those screens (but a single list on smaller screens), you can use the same two layouts from the previous section for single and two-pane layouts, but instead of the large size qualifier, use sw600dp to indicate the two-pane layout is for screens on which the smallest-width is 600 dp.

关于android - 在 android 中使用的最佳限定符是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48682984/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com