首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

给图片的边沿加上光晕

2012-06-26 
给图片的边缘加上光晕ImageView v (ImageView)findViewById(R.id.image)//一定要给ImageView加上几个像

给图片的边缘加上光晕





ImageView v = (ImageView)findViewById(R.id.image);//一定要给ImageView加上几个像素的Padding,要不然效果出来不了Paint p= new Paint();p.setColor(Color.RED);//红色的光晕BitmapDrawable bd = (BitmapDrawable) v.getDrawable();Bitmap b = bd.getBitmap();Bitmap bitmap = Bitmap.createBitmap(bd.getIntrinsicWidth(), bd.getIntrinsicHeight(), Config.ARGB_8888);Canvas canvas = new Canvas(bitmap);canvas.drawBitmap(b.extractAlpha(), 0, 0, p);StateListDrawable sld = new StateListDrawable();sld.addState(new int[]{android.R.attr.state_pressed}, new BitmapDrawable(bitmap));v.setBackgroundDrawable(sld);


参考http://gundumw100.iteye.com/blog/1205547#comments

热点排行