【问题标题】:Android won't use my long (wide aspect ratio) drawable images on long devicesAndroid 不会在长设备上使用我的长(宽纵横比)可绘制图像
【发布时间】:2023-04-04 20:03:01
【问题描述】:

我有一个多页面应用程序,除了图像加载外,它运行良好。每个页面都有一个全屏图像。我有 5 个可绘制文件夹——默认的一个没有任何页面图像,然后是这四个:

  • drawable-long
  • drawable-notlong
  • drawable-long-xhdpi
  • drawable-notlong-xhdpi

我的应用设置为仅横向。 notlong 中的图像文件是 4x3 纵横比。在long 中,它们的纵横比为 16x9。

在 Nexus 7 和 5 上,两种设备都报告屏幕类型为长屏幕,但使用来自 drawnble-notlong-xhdpi 的 4x3 图像。我怎样才能让他们使用long 图像?

如果我删除两个 notlong 文件夹,在应用启动时我会在图像资源上获得一个 NotFoundException(这会使应用崩溃)。

我确实添加了等效的 layout 视图,但仍显示 4x3 图像。

【问题讨论】:

    标签: android android-drawable screen-orientation android-image


    【解决方案1】:

    这是Android resource notlong / long identifiers not working 的副本,因为事实证明存在一个错误——我的代码告诉我屏幕是否过长是错误的。对于 Nexus 7,1920/1200 = 1.6,低于问答链接中提到的触发长视图的 1.667 比率。所以 Android 工作正常,但正常的纵横比可能与 4x3 相差很大,因此必须考虑到这一点。

    【讨论】:

      猜你喜欢
      • 2019-12-22
      • 1970-01-01
      • 1970-01-01
      • 2018-12-04
      • 1970-01-01
      • 2012-05-06
      • 1970-01-01
      • 2011-12-29
      • 1970-01-01
      相关资源
      最近更新 更多