i am trying to change the color of horizontal progress bar but it is not changing. i did some googling and gone through some example given in ur site. But i am not getting success to change the color accurately.
i used progressBar.setProgressDrawable(Drawable d)
but it sets the background color of the whole progress bar view instead of setting the background color of only the bar itself.
Please, any body help me.
thanks
Hi I am using this code in my project. I hope it works for you.
// Create ProgressBar in your layout file.
<ProgressBar
android:id="@+id/yourid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:progressDrawable="@drawable/slider"
/>
// Create .xml file in your drawable folder with name slider.
<?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/grey_bar_music"/>
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/blue_bar_music" />
</item>
</layer-list>
//grey_bar_music ->Background image name for your progressbar.
//blue_bar_music->Progress bar change color using this image when it start from 0.
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