一个关于 imageView 设置 scaleType 的问题。

  就在刚才 晚上9 点多的时候,我的一个外包伙伴发一个工程代码我,叫我去看下这样一个"bug",说折腾了很久,图片选择器在选择完图片后,就要显示图片到界面上,大家可以想象下 微信 发表图片,因为我们相机的图片肯定是 长宽都不一致的,为了统一格式,一般都是把要显示出来的 imageView 设置成 scaleType = centerCrop 或者 center。

  问题就是:他在设置了上面的属性后,宛然无效!imageView 设置成 scaleType = centerCrop 或者 center,对图片没效果。

  先上事例图:

  理想效果 和 问题效果(左->右):

   一个难倒 3年 android开发经验 " 工程师 " 的 "bug" 一个难倒 3年 android开发经验 " 工程师 " 的 "bug"

  公用的 xml:

 1 <RelativeLayout xmlns:andro
 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:paddingBottom="@dimen/activity_vertical_margin"
 6     android:paddingLeft="@dimen/activity_horizontal_margin"
 7     android:paddingRight="@dimen/activity_horizontal_margin"
 8     android:paddingTop="@dimen/activity_vertical_margin"
 9     tools:context=".MainActivity" >
10 
11     <LinearLayout
12         android:
13         android:paddingLeft="10dp"
14         android:orientation="horizontal"
15         android:layout_width="wrap_content"
16         android:layout_height="wrap_content">
17         
18 
19 
20     </LinearLayout>
21 
22 
23 </RelativeLayout>
View Code

相关文章: