Scale a background image or drawable?

by Sam » Thu, 10 Sep 2009 00:47:40 GMT

Sponsored Links

On a layout I want to scale the background image (keeping it's aspect
ratio) to the space allocated when the page gets created. Anyone have
any idea how to do this?

I am using layout.setBackgroundDrawable() and am using a
BitmapDrawable to setGravity for clipping and filling, but don't see
any option for scaling.


Scale a background image or drawable?

by Sam » Fri, 25 Sep 2009 10:37:45 GMT

 Thanks! It worked great with some tweaking for what I needed.

> Drawable:

Sponsored Links

Scale a background image or drawable?

by Sam » Fri, 25 Sep 2009 10:38:01 GMT

 Thanks! It worked great for what I needed to do.

> Drawable:

Other Threads

1. Screen orientation from code / Permissions to use Surface.SetOrientation

Hello all,

I'm trying to set screen orientation from code. I couldn't find any
leads so I went digging and found Surface.SetOrientation. Trying to
use it gave a permissions error referring to
android.permission.ACCESS_SURFACE_FLINGER, so I added:


To my manifest.

However now I get:

WARN/PackageManager(51): Not granting permission
android.permission.ACCESS_SURFACE_FLINGER to package
com.flatfeetpete.androidhello (protectionLevel=2 flags=0x44).

When the app starts, and then the same error.

Is there an easier way to change the orientation from code? It seems
like an odd thing to need permission for if I'm running my own app.


2. How to package application for upload to websites from Eclipse IDE?

Hello everyone,

I have gotten the to point of uploading my application for other
people to try.  Is there a specific method for packaging together your
files for upload to different services?  I had read in the
documentation there is a standard file extension for android
applications, but for the life of me, I can't find it again.

Any help would be greatly appreciated.



3. TextSwitcher

4. Implementing collision detection (Game)

5. Android Rap Song

6. How to install Android on imate

7. GPS Code Sample