【问题标题】:Android - ImageView not showing on certain phonesAndroid - ImageView 未在某些手机上显示
【发布时间】:2016-12-22 11:49:48
【问题描述】:

ImageView 似乎没有针对旧手机显示。它在我的 S6 Edge 和 HTC M9 上显示良好。但是,当我在 S3 或 HTC M7 上尝试时,ImageView 不会出现。

我尝试使用 4.7" 屏幕和 5.0.2 版本创建 AVD,但图像在模拟器上显示正常,所以我不确定它可能是什么。我选择 4.7" 和 5.0.2 的原因是因为 S3 和 M7 符合这些规格。

我在 drawables 文件夹中有图片,有 5 个不同的版本(hdpi、mdpi、xhdpi、xxhdpi 和 xxxhdpi。我的 XML 如下:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/logo"
    android:layout_centerInParent="true"
    android:id="@+id/splashImage"/>

有人知道为什么ImageView 没有出现在这些手机上,而是出现在具有相似规格和更新手机的模拟器上吗?

【问题讨论】:

  • 在活动打开时发布 logcat
  • 可能是硬件加速的问题。您可以尝试在视图上调用setLayerType(View.LAYER_TYPE_SOFTWARE, null)

标签: android image imageview screen-resolution android-version


【解决方案1】:

在Application标签的AndroidManifest.xml文件中设置以下代码行。

                  android:hardwareAccelerated="false"

【讨论】:

  • 谢谢,徽标现在按预期显示!我有一个类似的问题,即进度条的颜色在旧版本的 android 上没有改变,这种硬件加速是否也会导致问题?
  • 在旧版本的android上更改进度条的颜色不会导致任何问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-14
  • 1970-01-01
  • 2015-07-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多