android - 屏幕密度和图像尺寸

标签 android android-drawable android-resources screen-resolution android-resolution

Android 开发者您好,

我想知道如何选择drawable的尺寸;例如,我想在我的应用程序中插入一张图像,该图像应插入到 xxhdpi、xhdpi、hdpi、mdpi 和 ldpi 中,其尺寸(像素)是多少?

我在 GitHub 上分析了许多 Android 应用程序,它们使用随机图像大小(像素)来实现不同的密度。

最佳答案

To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratio between the six generalized densities. For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens, all the different sizes should be:

  • 36x36 (0.75x) for low-density
  • 48x48 (1.0x baseline) for medium-density
  • 72x72 (1.5x) for high-density
  • 96x96 (2.0x) for extra-high-density
  • 144x144 (3.0x) for extra-extra-high-density
  • 192x192 (4.0x) for extra-extra-extra-high-density

来源:https://developer.android.com/guide/practices/screens_support.html#DesigningResources

关于android - 屏幕密度和图像尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44489892/

相关文章:

android - 如何创建转换为单张 Material 的 float 操作按钮

android - 多个方向更改后,具有背景状态的 ImageView 崩溃

android - 防止在 Android 应用程序代码中将号码更改为本地

android R.integer 在创建数组时返回不正确的极大值导致内存不足

android - 以编程方式更改按钮图像 drawableLeft 无法在 android 中工作

android startActivityForResult 正在终止父 Activity 中的线程

带抽屉导航的 Android 中心标题

android - 如何在整个应用程序中以 native react 打开 XMPP 连接(使用 xmpp.js)?

android - 如何以编程方式修改可绘制对象的颜色

android - 如何创建这个可绘制的形状