Bitmap tileMode bits bug fixed?

I am having problems when my resource using the resource uses tileMode replay. In some cases, the image is simply stretched, and sometimes it repeats.

The following are the xml files that I use to create button states:

A line of images used to repeat fragments.

Image drawable used for tile repeated

^^^^^^^^^^^^^^

btn_menu_item.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android" android:constantSize="true" android:visible="true" android:variablePadding="true"> <!-- selected --> <item android:state_selected="true" android:drawable="@drawable/menu_item_selected"/> <!-- focused --> <item android:state_focused="true" android:drawable="@drawable/menu_item_pressed"/> <!-- pressed --> <item android:state_pressed="true" android:drawable="@drawable/menu_item_pressed"/> <!-- normal --> <item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/menu_item_normal"/> </selector> 

menu_item_normal.xml

 <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_selected="true"> <shape android:shape="rectangle"> <gradient android:startColor="#757575" android:endColor="#929292" android:angle="90"/> </shape> </item> <item> <bitmap android:src="@drawable/menu_lines_texture" android:tileMode="repeat" android:dither="true"/> </item> </layer-list> 

menu_item_pressed.xml

 <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_selected="true"> <shape android:shape="rectangle"> <gradient android:startColor="#dd4e00" android:endColor="#c64600" android:angle="90"/> </shape> </item> <item> <bitmap android:src="@drawable/menu_lines_texture" android:tileMode="repeat" android:dither="true"/> </item> </layer-list> 

Please see the images below exactly what I am talking about.

Normal state image properly repeatedPressed state image not repeated but stretched

+17
android android-layout
Sep 28 '11 at 16:09
source share
2 answers

This is a known bug, partially fixed in Android 3.0 and fully fixed in ICS.

+22
Sep 30 '11 at 19:25
source share

We had a similar problem written for 3.2 on a Sony Google TV device. We noticed a very similar background rotation associated with using android:tileMode="repeat" in the bitmap as the background image.

In this case, the correction was to turn off hardware acceleration in a view containing the so-called bitmap (from a function in our activity):

 View tile_holder = this.findViewById(R.id.tile_holder); tile_holder.setLayerType(View.LAYER_TYPE_SOFTWARE, null); 
+2
Nov 20 '12 at 19:15
source share



All Articles