XML绘制位图TILEMODE错误? [英] XML drawable Bitmap tileMode bug?
本文介绍了XML绘制位图TILEMODE错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的地方绘制资源使用TILEMODE重复的问题。在一些情况下,图像被刚拉伸,有时它被适当重复进行。
I'm having issues where my drawable resource uses the tileMode repeat. In some cases the image is just stretched and sometimes it is properly repeated.
下面是XML文件,我用它来创建按钮状态:
The following are the xml files I use to create the button states:
用于平铺图像绘制重复的
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 of what exactly I'm talking about.
推荐答案
这是一个已知的bug,部分固定的Android 3.0,并完全固定在ICS。
This is a known bug, partially fixed in Android 3.0 and completely fixed in ICS.
这篇关于XML绘制位图TILEMODE错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文