I would like to have this seekbar in my Android project :
This is my seekbar :
<SeekBar
android:id="@+id/seekBar_luminosite"
android:layout_width="@dimen/seekbar_width"
android:layout_height="@dimen/seekbar_height"
android:minHeight="15dp"
android:minWidth="15dp"
android:maxHeight="15dp"
android:maxWidth="15dp"
android:progress="@integer/luminosite_defaut"
android:progressDrawable="@drawable/custom_seekbar"
android:thumb="@drawable/custom_thumb" />
This is my custom_thumb.xml :
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<gradient
android:angle="270"
android:endColor="@color/colorDekraOrange"
android:startColor="@color/colorDekraOrange" />
<size
android:height="35dp"
android:width="35dp" />
</shape>
This is my custom_seekbar.xml :
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@android:id/background"
android:drawable="@drawable/seekbar"/>
<item android:id="@android:id/progress">
<clip android:drawable="@color/colorDekraYellow" />
</item>
</layer-list>
This is my seekbar.png (background) :
No shadow and no rounded borders in the bar...
I really not understand how I can do.
For future readers!
Starting from material-components-android 1.2.0-alpha01, you can use new
slider
componentex:
Modify
thumbSize
,thumbColor
,trackColor
accordingly.Note: Track corners are not round.
android:minHeight android:maxHeight is important for that.
seekbar_bg.xml
seekbar_thumb.xml
First at all, use
android:splitTrack="false"
for the transparency problem of your thumb.For the seekbar.png, you have to use a 9 patch. It would be good for the rounded border and the shadow of your image.
You can try progress bar instead of seek bar
At first courtesy goes to @Charuka .
DO
You can use
android:progressDrawable="@drawable/seekbar"
instead ofandroid:background="@drawable/seekbar"
.progressDrawable used for the progress mode.
You should try with
android:minHeight
android:minWidth
FYI:
Using android:minHeight and android:maxHeight is not good solutions .Need to rectify your Custom Seekbar (From Class Level) .
You can use the
Slider
in the Material Components Library.Use these attributes to customize the colors.
app:activeTrackColor
: the active track colorapp:inactiveTrackColor
: the inactive track colorapp:thumbColor
: to fill the thumbSomething like:
It requires the version 1.2.0 of the library.