Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does android:scaleType="fitCenter" only work with fix Layout_width and Layout_height attributes?

Tags:

I use Layout_width="fill_parent" and Layout_height="wrap content". If an image is bigger than the ImageView, it will be downscaled perfectly.

However, I never got it working to upscale smaller images. I tried any combination of ScaleType and "AdjustViewBounds": it always stays in its own size in the middle of the image view. Here is the code...

 <LinearLayout         android:id="@+id/LinearLayout02"         android:layout_height="wrap_content"         android:background="@drawable/content_bg"         android:orientation="vertical"         android:padding="5dp"         android:layout_width="fill_parent"         android:layout_marginLeft="1px">         <ImageView           android:layout_height="wrap_content"           android:src="@drawable/test"           android:id="@+id/ImageViewTest"           android:layout_width="fill_parent"           android:adjustViewBounds="true"           android:scaleType="center"></ImageView> </LinearLayout> 
like image 299
OneWorld Avatar asked Sep 24 '10 08:09

OneWorld


1 Answers

I just found a way to make it work.

This works in 2.1(AVD) & 4.1.2(device)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <ImageView         android:id="@+id/imageView1"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:scaleType="fitCenter" />  </LinearLayout> 
like image 150
Jack L Avatar answered Sep 21 '22 15:09

Jack L