Android
seek bar
styling
UI design
mobile development

Android - styling seek bar

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

A default Android SeekBar is functional but often does not match the visual language of a production app. Styling the track, thumb, tick behavior, and state feedback can make interactions feel deliberate and polished. This guide covers a maintainable approach using drawables, theme attributes, and runtime hooks.

Structure of a Styled SeekBar

A SeekBar is visually composed of two primary parts: the progress track and the draggable thumb. You can style both with XML drawables and then apply them in layout or theme.

Start with a clean layout definition:

xml
1<SeekBar
2    android:id="@+id/volumeSeek"
3    android:layout_width="match_parent"
4    android:layout_height="wrap_content"
5    android:max="100"
6    android:progress="35"
7    android:progressDrawable="@drawable/seekbar_track"
8    android:thumb="@drawable/seekbar_thumb"
9    android:splitTrack="false"
10    android:paddingStart="16dp"
11    android:paddingEnd="16dp" />

splitTrack set to false keeps the track continuous behind the thumb, which is often preferred for custom visuals.

Custom Track and Thumb Drawables

Use a layered drawable for the track so you can control background and filled progress independently.

xml
1<!-- res/drawable/seekbar_track.xml -->
2<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3    <item android:id="@android:id/background">
4        <shape android:shape="rectangle">
5            <size android:height="6dp" />
6            <corners android:radius="3dp" />
7            <solid android:color="#D8DEE6" />
8        </shape>
9    </item>
10
11    <item android:id="@android:id/progress">
12        <clip>
13            <shape android:shape="rectangle">
14                <size android:height="6dp" />
15                <corners android:radius="3dp" />
16                <solid android:color="#2F7DF6" />
17            </shape>
18        </clip>
19    </item>
20</layer-list>

Create a stateful thumb so pressed interaction is visible:

xml
1<!-- res/drawable/seekbar_thumb.xml -->
2<selector xmlns:android="http://schemas.android.com/apk/res/android">
3    <item android:state_pressed="true">
4        <shape android:shape="oval">
5            <size android:width="24dp" android:height="24dp" />
6            <solid android:color="#1F5CC0" />
7        </shape>
8    </item>
9    <item>
10        <shape android:shape="oval">
11            <size android:width="20dp" android:height="20dp" />
12            <solid android:color="#2F7DF6" />
13        </shape>
14    </item>
15</selector>

These resources are lightweight and easy to theme across screens.

Hooking Interaction in Kotlin

Styling is only half of the experience. Listen to progress changes and update UI feedback such as labels or previews.

kotlin
1val seekBar = findViewById<SeekBar>(R.id.volumeSeek)
2val valueLabel = findViewById<TextView>(R.id.volumeLabel)
3
4seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
5    override fun onProgressChanged(bar: SeekBar?, progress: Int, fromUser: Boolean) {
6        valueLabel.text = "Volume: $progress"
7    }
8
9    override fun onStartTrackingTouch(bar: SeekBar?) {
10        bar?.alpha = 0.95f
11    }
12
13    override fun onStopTrackingTouch(bar: SeekBar?) {
14        bar?.alpha = 1.0f
15    }
16})

For accessibility, keep contrast high and ensure thumb size remains touch friendly. If you use very thin tracks, keep thumb hit area generous so drag interactions remain reliable.

Theme Integration and Reuse

When several screens use the same slider style, move configuration into shared resources. You can define color values in your theme and keep drawable files stable. This avoids copy and paste edits and keeps behavior consistent as branding changes.

xml
1<!-- res/values/colors.xml -->
2<color name="seek_track">#D8DEE6</color>
3<color name="seek_progress">#2F7DF6</color>
4<color name="seek_thumb_pressed">#1F5CC0</color>

With shared values, your design team can update one place and propagate across features. It also helps testing because each style variant is traceable to a single source of truth.

If your app supports large text or custom display scaling, validate that labels near the slider still fit without clipping. The SeekBar itself might render correctly while supporting text wraps badly, which still harms usability.

Common Pitfalls

A common issue is forgetting right-to-left layout behavior. Progress direction may look reversed in some locales if custom drawables assume left-to-right flow. Test on a right-to-left emulator profile.

Another pitfall is using hardcoded colors that ignore dark or light theme variants. Prefer color resources and theme attributes so the SeekBar stays readable in all app modes.

Performance problems can appear when heavy vector effects are used for the thumb on older devices. Keep drawables simple unless animation quality is critical.

Teams also forget disabled states. A polished component needs a clear inactive style so users understand that interaction is intentionally blocked.

Summary

  • Style track and thumb separately using reusable XML drawables.
  • Use splitTrack and shape sizing to control final visual behavior.
  • Connect progress callbacks to labels or previews for immediate feedback.
  • Reuse theme-aware color resources so updates stay centralized.
  • Validate accessibility, right-to-left behavior, and disabled states.

Course illustration
Course illustration

All Rights Reserved.