본문 바로가기
📱 Android

[Android / Kotlin] Custom SeekBar

by 콩드로이드 2019. 11. 15.

SeekBar를 Custom해서 사용했는데, 깔끔하게 사용하려면 조정해야할 부분이 좀 있었다

 

보통 SeekBar는 Custom으로 많이 사용하니 까먹지 말자..! 

 

<SeekBar.xml>

 

 <SeekBar
        android:id="@+id/sb"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@null"
        android:max="100"
        android:progressDrawable="@drawable/progress_drawable"
        android:splitTrack="false"
        android:thumb="@drawable/progress_thumb"/>

 

1. android:background="@null"

  Thumb을 이동시키면 Ripple Effect효과가 나타나는데 이 효과를 없애기 위해서 사용

 

2. android:progressDrawable="@drawable/이미지명"

  Bar의 background를 적용

 

 

3. android:splitTrack="false"

 

seek1                                                                                               seek2

seek1처럼 Thumb를 커스텀하면 좌우에 여백이 생긴다

seek2처럼 변경시키기 위해 splitTrack 적용

 

4. android:thumb="@drawable/이미지명"

 

Thumb의 background 적용