您的位置:首页 > 移动开发 > Android开发

背景圆角以及图片圆角处理

2012-03-28 14:15 393 查看
转:http://hi.baidu.com/sip59/blog/item/8111454b4c0ca42e09f7ef8f.html 1.配置文件实现

icon_home_shape_overlay如下

或者直接使用一种效果

然后 android:background="@drawable/my_shape_file"

2.图片本身加上圆角

[c-sharp] view
plaincopyprint?

Bitmap myCoolBitmap = ... ; // <-- Your bitmap you want rounded int w = myCoolBitmap.getWidth(), h = myCoolBitmap.getHeight(); Bitmap rounder = Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(rounder); Paint xferPaint = new Paint(Paint.ANTI_ALIAS_FLAG); xferPaint.setColor(Color.RED); canvas.drawRoundRect(new RectF(0,0,w,h), 20.0f, 20.0f, xferPaint); xferPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN)); canvas.drawBitmap(myCoolBitmap, 0,0, null); canvas.drawBitmap(rounder, 0, 0, xferPaint);   

或者

 

[c-sharp] view
plaincopyprint?

public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) { Bitmap output = Bitmap.createBi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android null file c