When playing music, we need a seekbar. Seekbar default look like
this.
We can make it better.
In folder drawable, create file name custom.xml.
<?xml version="1.0"
encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#16BC5C"
/>
<stroke
android:width="1dp"
android:color="#16BC5C"
/>
<size
android:height="20dp"
android:width="20dp"
/>
</shape>
Create file name border.xml.
<?xml version="1.0"
encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners
android:radius="5dp"
/>
<gradient
android:angle="270"
android:startColor="#33000000"
android:centerColor="#11000000"
android:endColor="#11000000"
android:centerY="0.2"
android:type="linear"
/>
</shape>
</item>
</layer-list>
Create file name seekbar_progress.xml
<?xml version="1.0"
encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:id="@+id/progressshape"
>
<clip>
<shape
android:shape="rectangle"
>
<size android:height="5dp"/>
<corners
android:radius="5dp"
/>
<solid android:color="#58ACFA"/>
</shape>
</clip>
</item>
</layer-list>
Create file name seekbar_style.xml.
<?xml version="1.0"
encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:id="@android:id/background"
android:drawable="@drawable/border"
>
</item>
<item
android:id="@android:id/progress"
>
<clip
android:drawable="@drawable/seekbar_progress"
/>
</item>
</layer-list>
Now file seekbar.xml like this.
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="2dp"
android:minHeight="2dp"
android:progressDrawable="@drawable/seekbar_style"
android:thumb="@drawable/custom"
/>
Run to see result, you can change color as you like.
No comments:
Post a Comment