发现ImageView 默认private boolean mAdjustViewBounds = false;
也就是说默认imageview不是按比例缩放的。
需要自己设置为true
/**
* Set this to true if you want the ImageView to adjust its bounds
* to preserve the aspect ratio of its drawable.
* @param adjustViewBounds Whether to adjust the bounds of this view
* to presrve the original aspect ratio of the drawable
*
* @attr ref android.R.styleable#ImageView_adjustViewBounds
*/
@android.view.RemotableViewMethod
public void setAdjustViewBounds(boolean adjustViewBounds) {
mAdjustViewBounds = adjustViewBounds;
if (adjustViewBounds) {
setScaleType(ScaleType.FIT_CENTER);
}
}
android:adjustViewBoundsSet this to true if you want the ImageView to adjust its bounds to preserve the aspect ratio of its drawable.
posted on 2012-05-31 12:08
汪杰 阅读(247)
评论(0) 编辑 收藏 引用 所属分类:
Java