-1

I want to define maxHeight for an image that it's adjustViewBounds has been set to true. in this way adt automatically keeps aspect ratio. is there any way to gain this approach without keeping aspect ratio?

this is the image, and i want to stretch it from sides, without being displaced:

this is the image, and i want to stretch it from sides, without being displaced

Branky
  • 373
  • 8
  • 23

3 Answers3

1

try this

<ImageView 
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@drawable/your image name"
        android:scaleType="fitXY"/>
saa
  • 1,538
  • 2
  • 17
  • 35
  • this one does the stretch, but is there any way stretch a bit?! – Branky Dec 27 '13 at 11:05
  • 1
    if u want full screen try this... android:layout_width="match_parent" – saa Dec 27 '13 at 11:06
  • If u want to stretch to particular distance.. please use android:layout_width="200dp" change the value, based on that ur image view will change – saa Dec 27 '13 at 11:08
1

You can do like this

 <ImageView
    android:layout_width="100dp"
    android:layout_height="400dp"
    android:src="@drawable/ic_launcher" 
    android:scaleType="fitXY"/>
Ana
  • 841
  • 10
  • 28
0

I think android:scaleType="fitXY" is what you are looking for.

Damien R.
  • 3,383
  • 1
  • 21
  • 32
  • can you explain it?what is this for? – Branky Dec 27 '13 at 10:45
  • It will fill your layout such as background – Daryn Dec 27 '13 at 10:47
  • This is to set as an ImageView parameter. The ScaleType parameter is "Options for scaling the bounds of an image to the bounds of this view." More informations here: http://developer.android.com/reference/android/widget/ImageView.ScaleType.html – Damien R. Dec 27 '13 at 10:48