0
내가 원이 화면의 폭과 높이안드로이드 사용자 정의보기 전체보기
public class BubbleView extends ViewGroup {
private Paint borderPaint,imagePaint;
private Bitmap bmp;
private long expires;
private RectF bounds = new RectF();
public BubbleView(Context context) {
super(context);
init();
}
void init(){
borderPaint = new Paint();
borderPaint.setStyle(Style.FILL_AND_STROKE);
borderPaint.setColor(getContext().getResources().getColor(R.color.green));
imagePaint = new Paint();
imagePaint.setStyle(Style.FILL);
setWillNotDraw(false);
}
void setImage(Bitmap bmp){
this.bmp = bmp;
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawArc(bounds, 0, 360, true, borderPaint);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
bounds = new RectF(0f, 0f,(float) w,(float) h);
invalidate();
}
을 차지 타원형으로 그리기 유지 원을 그릴 수있는 커스텀 뷰를 작성하려고 해요로 확대 }
onsidechanged 메서드의 일부가 올바르게 작동하지 않습니다. 오른쪽 및 아래쪽 경계를 정수로 설정하면 의도 한대로 작동합니다. 작동 예를
bounds = new RectF(0f, 0f,100f,100f);
에 대한
.
3) ViewGroup이 아닌 ViewGroup을 확장합니다. 4) this.bmp가 사용되지 않습니다. – pskink