MiguelC MiguelC - 1 year ago 163
Android Question

Full screen background image in an activity

I see many applications that use a full-screen image as background.
This is an example:

Full screen background image

I want to use this in a project, the best way I've found so far to do this is to use an image with a large size, put it in a

and use
android: adjustViewBounds="true"
to adjust the margins

The problem is that if a screen with a very high resolution, the image falls short.

Another option I thought of is to use the image in a
, with
as background... this stretches the image, but I think the result is not very good.

I can ask how would you do it?

Thanks in advance

Answer Source

There are several ways you can do it.

Option 1:

Create different perfect images for different dpi and place them in related drawable folder. Then set


Option 2:

Add a single large image. Use FrameLayout. As a first child add an ImageView. Set the following in your ImageView.

android:scaleType = "centerCrop"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download