android - 可绘制限定符,位图在 HTC with Android 4+ 屏幕旋转后未正确更改

标签 android rotation drawable htc-android

我在 HTC Sensation 和 HTC One S 上遇到可绘制对象问题。

我在 drawable-nodpi 文件夹中有图形:

icon_l.png
icon_m.png

在 drawable-hdpi 文件夹中,我有带有代码的文件 icon.xml:

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/icon_l" />

在 drawable-land-hdpi 文件夹中,我有带有代码的文件 icon.xml:

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/icon_m" />

在 drawable 文件夹中我有选择器文件 button.xml 代码:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="true" android:drawable="@drawable/icon_pressed" />
  <item android:drawable="@drawable/icon" />
</selector>

在布局中我有:

<ImageButton android:src="@drawable/button"/>

一切正常,几乎在所有手机和平板电脑上:横向图形较小,当我返回纵向图形时再次变大;

但在 HTC sensation 和 HTC one S 上没有:当我旋转手机时,此手机上的图形会随机加载。

我想这可能是任何缓存? 我尝试将 setContentView 设置为其他布局并再次重新加载正确的布局,但它不起作用。

最佳答案

我能够在运行库存 ICS Android 的 Sensation 上复制此行为。到目前为止我发现的唯一解决方法是在每个 HDPI 文件夹中放置一个额外的 button.xml 副本。

关于android - 可绘制限定符,位图在 HTC with Android 4+ 屏幕旋转后未正确更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13626732/

相关文章:

android - 带参数的多模块 Android 架构中的导航

ios - 颠倒呈现 UIActivityViewController

android - 在 Selector drawable 中更改 Padding

android - 将 ImageView 转换为 Canvas 的 Drawable

android - 了解使用 ColorMatrix 和 ColorMatrixColorFilter 修改 Drawable 的色调

android - fine_location 权限 android 的常量

android - Android中的多声道录音

使用套接字的 Android 点对点应用程序

matlab - 从 3D 数组中提取任意旋转的数据平面作为 2D 数组

ios - 如何处理 iOS 中的不同方向