안드로이드 개발 정보
(글 수 1,069)
ImageView 를 roundRec 으로 처리한 클래스 입니다.
roundRec 형태의 띠 를 이미지위에 덮어씌우는 방법으로 처리했습니다..
이방법 외에 여러가지 방법이 있을수 있습니다.
정석은 아니오니 참고만 하시길 바랍니다..
public class ProfileImageView extends ImageView {
private int n = 5;
private int rWidth = 0;
private int rHeight = 0;
public ProfileImageView(Context context) {
super(context);
}
public void setHeight(int h){
rHeight = h;
}
public void setWidth(int w){
rWidth = w;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
float[] outerR = new float[] { n,n,n,n,n,n,n,n };
RectF inset = new RectF(5, 5, 5, 5); // 모서리 둥근 사각형 띠의 두께.
float[] innerR = new float[] { n,n,n,n,n,n,n,n };
ShapeDrawable mDrawables = new ShapeDrawable(new RoundRectShape(outerR, inset, innerR));
mDrawables.getPaint().setColor(Color.WHITE);
mDrawables.getPaint().setAntiAlias(true);
mDrawables.setBounds(-2,-2,rWidth+1, rHeight+1);
mDrawables.draw(canvas);
}
}



