代码如下
xml :
<FrameLayout android:layout_width="match_parent" android:layout_height="300dp"> <ImageView android:id="@+id/old_image" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitXY" android:src="@drawable/test"/> <ImageView android:id="@+id/blur_image" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitXY"/> </FrameLayout>
Activity :
private ImageView old_image, blur_image; private Bitmap mBitmap, overlay; @Override public void onCreate(Bundle savedInstanceState) {Create(savedInstanceState); setContentView(R.layout.main); old_image = (ImageView) findViewById(R.id.old_image); blur_image = (ImageView) findViewById(R.id.blur_image); //设置模糊图片的长和宽 ViewGroup.LayoutParams params = LayoutParams(); params.height = 600; params.width = ViewGroup.LayoutParams.MATCH_PARENT; blur_image.setLayoutParams(params); //得到模糊图片 if (null != overlay) {blur_image.setImageBitmap(overlay); }//将old_image对象转化为bitmap对象 old_image.buildDrawingCache(); mBitmap = DrawingCache(); mBitmap = ((BitmapDrawable) Drawable()).getBitmap(); //这两个数字是控制模糊度的
本文发布于:2024-01-30 14:18:18,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170659550020604.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |