-1

I want to scale image loaded from sd card into the image view .

Problem is whenever i load from sd card the image comes as full screen and i have set all the parameters fill_parent viewbounds scaletype etc. as per other questions.

What should be the way to do it ?

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/Frame"
    android:layout_alignLeft="@+id/Load1"
    android:adjustViewBounds="true"
    android:cropToPadding="true"
    android:scaleType="fitXY"
    android:src="@android:drawable/alert_light_frame" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="14dp"
    android:scaleType="fitXY"
    android:src="@android:drawable/alert_light_frame" />

this is my image view code can u tell me what to change so that image comes according to the imageview size

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
Pallav Grover
  • 55
  • 2
  • 8

2 Answers2

0

Use fitCenter scaleType. In your layout definition, use the below attribute for your ImageViews

android:scaleType="fitCenter"
Leonel Machava
  • 1,501
  • 11
  • 19
0

If the imageview is big and if you try to load a big image then the layout is doing what it is supposed to do.

So either give a fixed width/height to the ImageView instead of wrap_content or you have to scale the imagedown based on your Phones screen size.

Try this link : How to scale down the image for better quality on Android? and some tips from here : How to scale an Image in ImageView to keep the aspect ratio

Community
  • 1
  • 1
Prakash Nadar
  • 2,694
  • 1
  • 19
  • 20