2016-10-29 3 views

답변

0

검색 바를 통해 빈보기 (3보기)를 추가하는 것이 가장 좋습니다. seek_bar를 기준으로 match_parent 높이, 2dp 너비의 뷰를 만듭니다. 더 많은 정보를 들어

다음은 내가 기본적인 수준에서 수행 한 것입니다 링크 Seek bar with divider

1

를 참조하십시오. http://stackoverflow.com/a/ [여기] (

public class SegmentedSeekBar extends android.support.v7.widget.AppCompatSeekBar { 

    private Paint progressPaint; 

    public SegmentedSeekBar(Context context) { 
     super(context); 
     init(); 
    } 

    public SegmentedSeekBar(Context context, AttributeSet attrs) { 
     super(context, attrs); 
     init(); 
    } 

    public SegmentedSeekBar(Context context, AttributeSet attrs, int defStyleAttr) { 
     super(context, attrs, defStyleAttr); 
     init(); 
    } 

    private void init() { 
     progressPaint = new Paint(); 
     progressPaint.setStyle(Paint.Style.FILL_AND_STROKE); 
     progressPaint.setColor(Color.LTGRAY); 
     progressPaint.setStrokeWidth(2.0f); 
    } 

    @Override 
    protected synchronized void onDraw(Canvas canvas) { 
     int halfHeight = getHeight()/2; 

     int pos; 
     float smallH = 10; 

     float div = (getWidth() - getPaddingRight() - getPaddingLeft())/(getMax()); 

     for (int i = 1; i < getMax(); i++) { 
      pos = (int) (div * i) + getPaddingLeft(); 

      canvas.drawLine(
        pos + 1.0f, 
        halfHeight - (halfHeight/2.0f), 
        pos + 1.0f, 
        halfHeight + (halfHeight/2.0f), 
        progressPaint); 
     } 

     super.onDraw(canvas); 
    } 
}