cnfw
cnfw

Reputation: 800

How do you scale and tile a bitmap drawable being used as a background?

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?

Thanks

Upvotes: 10

Views: 18508

Answers (1)

tiguchi
tiguchi

Reputation: 5410

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.

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

Upvotes: 8

Related Questions