Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to get ImageView to fill screen

Tags:

android

layout

I don't know how to get an image to fill the screen, have tried everything, maybe there is some particular layout I should be using..?

I'm using an ImageView, however this just fills about 70% of the screen, leaving blank space at the bottom...

At the moment i'm just using a LinearLayout and setting its background to my image. While this fills the screen, the image is slightly streched, which I don't want.

Any help would be greatly appreciated! :)

The code inside the ImageView tags of my layout file are:

android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:scaleType="centerCrop" 
android:adjustViewBounds="true" 
android:src="@drawable/image" 
like image 285
Shaw Avatar asked Feb 10 '12 15:02

Shaw


People also ask

How do you show the full size image in pop up when clicking the picture on android?

How to show the full size image in popup on clicking the image in android. Below is the code that will show the full size image in a dialog box popup without defining layout xml file . int a=v. getId(); intiger "a" will have the value equal to profile_pic if we touched on profile_pic imageview else we will get pro id .


3 Answers

//in your xml Image attribute as

android:scaleType="fitXY"

or //using thru programatically

imgview.setScaleType(ScaleType.FIT_XY);

Note: this applies to when the image is set with android:src="..." rather than android:background="..." as backgrounds are set by default to stretch and fit to the View.

like image 106
Padma Kumar Avatar answered Sep 18 '22 12:09

Padma Kumar


    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="centerCrop"
    android:adjustViewBounds="true"
    android:src="@drawable/image"

just change layout width and height which would work with both 'center' and 'centercrop'

like image 23
Revs Avatar answered Sep 20 '22 12:09

Revs


Use the below line in your Image View xml code.

android:scaleType="fitXY"
like image 44
Sunny Avatar answered Sep 20 '22 12:09

Sunny