Skip to content

Instantly share code, notes, and snippets.

@yushiro
Created October 20, 2014 23:34
Show Gist options
  • Save yushiro/a19d9d587e958a71e0f7 to your computer and use it in GitHub Desktop.
Save yushiro/a19d9d587e958a71e0f7 to your computer and use it in GitHub Desktop.
ImageView的裁剪
imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(45, 45)); imageView.setAdjustViewBounds(false); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(8, 8, 8, 8);
setScaleType的ScaleType.CENTER_CROP, 从图片的中央开始裁剪, 具体的ScaleType说明可以参考http://blog.sina.com.cn/s/blog_407abb0d0100mao1.html setAdjustViewBounds必须设置为false, 而且需要指定ImageView的layout_height, layout_width
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment