Horizontal progressbar with custom color

activity_main.xml <progressbar android:id=”@+id/progressBar” style=”?android:progressBarStyleHorizontal” android:layout_width=”match_parent” android:layout_height=”1dp” android:layout_margin=”0dp” android:max=”100″ android:padding=”0dp” tools:progress=”40″ android:progressDrawable=”@drawable/progress_drawable” app:layout_collapseMode=”pin”/> MainActivity.java ProgressBar mProgressBar = (ProgressBar) findViewById(R.id.progressBar); //somewhere when scrollin mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override…

Working example – changing drawable background in runtime, dynamically

Here is a short example code how to do it:
I’ve created xml file shape.xml and one method for flexible changing color of shape.

shape.xml:
[java]
<?xml version=”1.0″ encoding=”utf-8″?>
<shape xmlns:android=”http://schemas.android.com/apk/res/android” >
<solid android:color=”@android:color/holo_blue_bright” />
<corners android:radius=”30dp” />
<size
android:height=”15dp”
android:width=”15dp” />
</shape>
[/java]

And here is a method for flexible changing color:

Read more