如何缩放和平铺用作背景的位图drawable?

cw1*_*998 10 android android-layout

我在drawable bitmap xml文件中有以下代码.并且linearLayout的背景设置为它.

<?xml version="1.0" encoding="utf-8"?>
    <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/background_screen"
        android:tileMode="repeat"
        android:scaleHeight="10"
        android:scaleWidth="10"
        />
Run Code Online (Sandbox Code Playgroud)

图像拼贴确定,但不会缩放.我需要做什么/修复才能使其扩展?

谢谢

tig*_*chi 8

根据我的经验,最好为您定位的每个密度创建不同大小的位图.这样您就不必担心这些比例属性并在任何设备上获得清晰的结果.

没有为BitmapDrawables定义这些比例属性.它们存在于ScaleDrawables中,旨在扩展另一个drawable.看一下:

http://developer.android.com/guide/topics/resources/drawable-resource.html#Scale