如何缩放和平铺用作背景的可绘制位图? [英] How do you scale and tile a bitmap drawable being used as a background?

查看:69
本文介绍了如何缩放和平铺用作背景的可绘制位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在可绘制的位图xml文件中有以下代码.并设置了linearLayout的背景.

I have the following code in a drawable bitmap xml file. And the background of a linearLayout set to it.

<?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"
        />

图像平铺好,但无法缩放.我必须做/修复才能使其按比例缩放?

The image tiles OK, but it doesn't scale. What do I have to do/fix to get it to scale?

谢谢

推荐答案

以我的经验,最好为要定位的每种密度创建不同大小的位图.这样一来,您不必担心这些缩放比例属性,而在任何设备上都能获得清晰的结果.

In my experience it is better to create different sized bitmaps for each density you are targeting. That way you don't have to worry about these scale attributes and get crisp results on any device.

未为BitmapDrawables定义这些比例属性.它们存在于ScaleDrawables中,用于缩放另一个drawable.看看:

These scale attributes are not defined for BitmapDrawables. They exist for ScaleDrawables which are meant to scale another drawable. Have a look at:

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

这篇关于如何缩放和平铺用作背景的可绘制位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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