I have my own view of the indicator that I created.
as you can see in the first picture, everything is drawn correctly, but sometimes, when I close the application and start it again, it does not draw correctly (second image)
trying to figure out what could be causing this. perhaps caching?
this is my onDraw
code:
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); drawUnselected(canvas, mUnselectedPaint); drawSelected(canvas, mSelectedPaint); drawDone(canvas, mDonePaint); } private void drawDone(Canvas canvas, Paint mDonePaint) { for (Integer page : mDonePages) { canvas.drawBitmap(mDoneItemBitmap, dotCenterX[page], mDotTopY, mDonePaint); } } private void drawSelected(Canvas canvas, Paint mSelectedPaint) { float dist = ((mSelectedPaint.descent() + mSelectedPaint.ascent()) / 2); for (Integer page : mSelectedPages) { canvas.drawBitmap(mSelectedItemBitmap, dotCenterX[page], mDotTopY, mSelectedPaint); canvas.drawText("" + (page + 1), dotCenterX[page] + mDotRadius + dist, mDotTopY + mDotRadius - dist, mSelectedPaint); } } private void drawUnselected(Canvas canvas, Paint mUnselectedPaint) { int paddingTop = getPaddingTop(); for (int page = 0; page < mDotsNumber; page++) { Paint test = new Paint(); test.setColor(Color.BLACK); test.setStrokeWidth(30); canvas.drawBitmap(mUnSelectedItemBitmap, dotCenterX[page], mDotTopY, mUnselectedPaint); float dist = ((mNumbersPaint.descent() + mNumbersPaint.ascent()) / 2); canvas.drawText("" + (page + 1), dotCenterX[page] + mDotRadius + dist, mDotTopY + mDotRadius - dist, mNumbersPaint); if (page == mDotsNumber - 1) {
source share