I want to set the SeekBar like this:
But my SeekBar is looking like this:
That's mean it over the two small "sun"
Here is my code:
<SeekBar
android:id="@+id/seekBar"
android:layout_span="2"
android:layout_width="fill_parent"
android:progressDrawable="@drawable/background_custom"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:thumb="@drawable/thumb_custom"
android:minHeight="20dp"
android:maxHeight="40dp"
android:layout_height="45dp"
android:layout_centerVertical="true"
android:max="100"
android:progress="100"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:background="@drawable/my_back_ground"
/>
Xml of background_custom:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"
>
<shape>
<size
android:height="50dp"
android:width="50dp" />
<corners android:radius="50dp" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="#11ff00" />
<corners android:radius="30dp" />
</shape>
</clip>
</item>
</layer-list>
Xml of thumb_custom:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffe38c" />
<size
android:width="35dp"
android:height="35dp" />
<corners android:radius="35dp" />
<item android:id="@android:id/background"
android:drawable="@drawable/led_sang"/>
</shape>
Now go to the activity_main. xml create a layout and inside the layout add a SeekBar. Specify the height width of SeekBar and the max progress that you want to use set progress to 0. This will create a customized Seekbar inside activity_main.
If you are using default SeekBar provided by android Sdk then their is a simple way to change the color of that . just go to color. xml inside /res/values/colors. xml and change the colorAccent.
One possible solution would be to set seekBar. setMax(20) (or android:max="20" in XML), and whenever you use or display the value, multiply it by 10. The SeekBar would then appear to move at least 20 at a time.
Just add android:thumbTint="@color/yourColor" in your seekbar.
I already solve this problem by replace this line android:progressDrawable="@drawable/background_custom"
to android:progressDrawable="#80FFFF00"
. This will make the 50% transparent of the yellow color.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With