1

I'm working with an emulator screen set at 320x480 MDPI. I created a background image in fireworks with the exact size of 320x480 pixels, placed it in the drawable MDPI folder, and set it as an ImageView in hopes it would fill the entire background of the emulator. The problem is the background only fills vertically, but seems to leave empty space equally on the left and right horizontally.

Any idea what I'm doing wrong?

3 Answers3

1
<ImageView android:layout_width="fill_parent"
           android:layout_height ="fill_parent" 
           android:scaleType="fillXY" />

Note that this will cause it to scale in the X direction to fill the space, which will slightly distort the image.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
1

Any reason why you don't just setBackground on your root view?

Either way, filling the background in Android is a troublesome business. I suggest reading this question: Handling different screen resolutions for background images in Android

Community
  • 1
  • 1
Michael A.
  • 4,163
  • 3
  • 28
  • 47
0

please don't use a ImageView, just set the android:background property of the root layout in your xml. Look at this example:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/your_image_here" >
    .....
    </RelativeLayout>

I hope this helps you. Best Regards

vgarzom
  • 153
  • 10