android seek bar customization,

前端 未结 2 1815
情歌与酒
情歌与酒 2020-12-05 16:39

I need to customize a seek bar in such a way that, at pre determined time say , 30sec, I should have a dot on the seek bar. This duration varies for each and every video, so

2条回答
  •  自闭症患者
    2020-12-05 16:57

    The above answer is completely correct but the onDraw method could have been improved a little.

            @Override
            protected synchronized void onDraw(final Canvas canvas) {
                super.onDraw(canvas);
    
                final float width=getMeasuredWidth()-getPaddingLeft()-getPaddingRight();
                final float step=width/(float)(getMax());
    
                if (null != mDotsPositions && 0 != mDotsPositions.length && null != mDotBitmap) {
                    // draw dots if we have ones
                    for (int position : mDotsPositions) {
                        canvas.drawBitmap(mDotBitmap, position * step, 0, null);
                    }
                }
            }
    

提交回复
热议问题