androidrotationdrawablehtc-android

drawable qualifiers, Bitmaps aren't changed correctly after screen rotation on HTC with Android 4+


I have a problem with drawables on HTC Sensation and HTC One S.

I have graphics in drawable-nodpi folder:

icon_l.png
icon_m.png

In drawable-hdpi folder I have file icon.xml with code:

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

In drawable-land-hdpi folder I have file icon.xml with code:

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

In drawable folder I have selector file button.xml with code:

<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>

In layout I have:

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

Everything works ok, on almost all phones and tablets: graphics on landscape are smaller and when I back to portrait graphics are again bigger;

but not on HTC sensation and HTC one S: graphics on this phones are loaded randomly when I rotate phone.

I suppose that may be any cache? I tried setContentView to other layout and again reloaded correct layout, but it doesn't work.


Solution

  • I was able to duplicate this behavior on a Sensation running stock ICS Android. Only workaround I found so far was to put an extra copy of button.xml in each HDPI folder.