getRoundedCornerBitmap 클래스로 해주면 됩니다.
[##__##]
public class ImageRound extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView img = (ImageView)findViewById(R.id.image);
Bitmap bm = BitmapFactory.decodeResource(getResources(),
R.drawable.icon);
img.setImageBitmap(getRoundedCornerBitmap(bm, 10));
}
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = pixels;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
}
'Developer > Android' 카테고리의 다른 글
[Android]내 위치(위도,경도) 지역정보, 주소 알아보기 (1) | 2011.01.25 |
---|---|
[Android]Resource를 Bitmap으로 만들기. (2) | 2010.12.16 |
[Android] 안드로이드 가로, 세로 모드 막기 (0) | 2010.12.16 |
[WebView] ProgressBar 만들기 (1) | 2010.12.15 |
[Keyboard]키보드 강제로 열기 강제로 닫기 (0) | 2010.12.15 |