XML drawable Bitmap tileMode 错误? [英] XML drawable Bitmap tileMode bug?

查看:30
本文介绍了XML drawable Bitmap 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:

用于重复图块的可绘制图像

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

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

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.

推荐答案

这是一个已知错误,在 Android 3.0 中部分修复,在 ICS 中完全修复.

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

这篇关于XML drawable Bitmap tileMode 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆