2

android the image looks too small on screen, how to scale it to fit the screen? wrap_content does not seem to work

<RelativeLayout
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<ImageView
    android:layout_alignParentTop="true"
    android:layout_marginTop="100dip"
    android:id="@+id/imageview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/splash_screen"/>
<ProgressBar
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="20dip"
    android:id="@+id/progressbar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>
</RelativeLayout>
Michael SM
  • 715
  • 3
  • 11
  • 25
  • Use the DynamicImageView class explained here: http://stackoverflow.com/questions/13992535/android-imageview-scale-smaller-image-to-width-with-flexible-height-without-crop – goicox Nov 20 '14 at 00:06

3 Answers3

5

Add the following attribute to your ImageView to get it to scale as you like (will fill the size of your ImageView):

android:scaleType="fitXY"

I would actually change your width attribute as well. Your final XML could look like this:

<ImageView
    android:layout_alignParentTop="true"
    android:layout_marginTop="100dip"
    android:id="@+id/imageview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"
    android:src="@drawable/splash_screen"/>
Booger
  • 18,579
  • 7
  • 55
  • 72
  • This does not work as expected. The image extends to left edge of the screen as expected, but not to right, above and below. – Michael SM Jan 29 '13 at 19:42
0

After testing, the following works:

<ImageView
    android:layout_alignParentTop="true"
    android:layout_marginTop="100dip"
    android:id="@+id/imageview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="fitXY"
    android:src="@drawable/splash_screen"/>
Michael SM
  • 715
  • 3
  • 11
  • 25
-1

it's your image issue,may be the image contains unnecessarily enlarged background,crop the image,remove unnecessary background and then it will be solved

Apurba A
  • 71
  • 6