@Override protected void onMeasure(int widthSpec, int heightSpec) { int totalDiameter = 2*mRadius + getPaddingLeft() + getPaddingRight(); setMeasuredDimension(totalDiameter, totalDiameter); }
@Override protected void onMeasure(int widthSpec, int heightSpec) { int totalDiameter = 2*mRadius + getPaddingLeft() + getPaddingRight(); setMeasuredDimension(totalDiameter, totalDiameter); }
@Override protected void onDraw(Canvas canvas) { float wf = getWidth(); float hf = getHeight(); final float cx = wf/2; final float cy = hf/2; wf -= getPaddingLeft() + getPaddingRight(); hf -= getPaddingTop() + getPaddingBottom(); float rad = (wf < hf) ? wf/2 : hf/2; canvas.drawCircle(cx, cy, rad, mPaint); if (mLegend != null && mLegend.length() > 0) { canvas.drawText(mLegend, 0, mLegend.length(), cx, cy + mLegendPaint.getFontSpacing()/2, mLegendPaint); } // if we're in the middle of a drag, light up as a potential target if (mDragInProgress && mAcceptsDrag) { for (int i = NUM_GLOW_STEPS; i > 0; i--) { int color = (mHovering) ? WHITE_STEP : GREEN_STEP; color = i*(color | ALPHA_STEP); mGlow.setColor(color); canvas.drawCircle(cx, cy, rad, mGlow); rad -= 0.5f; canvas.drawCircle(cx, cy, rad, mGlow); rad -= 0.5f; } } }
@Override protected void onDraw(Canvas canvas) { float wf = getWidth(); float hf = getHeight(); final float cx = wf/2; final float cy = hf/2; wf -= getPaddingLeft() + getPaddingRight(); hf -= getPaddingTop() + getPaddingBottom(); float rad = (wf < hf) ? wf/2 : hf/2; canvas.drawCircle(cx, cy, rad, mPaint); if (mLegend != null && mLegend.length() > 0) { canvas.drawText(mLegend, 0, mLegend.length(), cx, cy + mLegendPaint.getFontSpacing()/2, mLegendPaint); } // if we're in the middle of a drag, light up as a potential target if (mDragInProgress && mAcceptsDrag) { for (int i = NUM_GLOW_STEPS; i > 0; i--) { int color = (mHovering) ? WHITE_STEP : GREEN_STEP; color = i*(color | ALPHA_STEP); mGlow.setColor(color); canvas.drawCircle(cx, cy, rad, mGlow); rad -= 0.5f; canvas.drawCircle(cx, cy, rad, mGlow); rad -= 0.5f; } } }