CodeWalker
CodeWalker

Reputation: 2368

How to make an ImageView take up the entire screen?

I am building an android application. I have dropped in an ImageView in my activity. The image centers itself in the middle leaving strips of white background on all four sides. I have used Toggle Height and Toggle Width but it does not help. I need the image to cover up the entire screen with no background visible. Kindly refer to the screenshot below.

Screenshot

Upvotes: 0

Views: 551

Answers (2)

ngrashia
ngrashia

Reputation: 9894

This is how I achieved full page image background in my app with background.png:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >

   ---- Other widgets here on top of the image ------
</LinearLayout>

Upvotes: 0

Kishan Dhamat
Kishan Dhamat

Reputation: 3784

Change to this:

 <ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY"
    android:src="@drawable/icon" />

If you have given margin or padding then remove it from layout.

Upvotes: 5

Related Questions