I created this progress bar for my app, but I cant get that yellow orangy color that appears to change to something like red or blue.
<ProgressBar
android:id="@+id/progress_bar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="250sp"
android:layout_height="wrap_content"
android:progress="2"
android:layout_marginTop="82dp"
android:max="3"
android:indeterminate="false"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true" />
above is my progress bar xml code.
Any help guys? :)
Thanks so much in advance! :)
In the stylesheet, we actually can use the element selector to target and add style rules to <progress> element. In this example, we change the background color, remove the border line, and make it rounded by adding a border radius at half of its height.
If you only want to change the progress bar color, you can simply use a color filter in your Activity's onCreate() method: ProgressBar progressbar = (ProgressBar) findViewById(R. id. progressbar); int color = 0xFF00FF00; progressbar.
If android version is 5.0 and above you just need to set
android:indeterminateTint="@color/BLACK"
android:indeterminateTintMode="src_in"
For lower version I use this
mProgressBar.getIndeterminateDrawable().setColorFilter(getResources()
.getColor(R.color.primary_color),PorterDuff.Mode.SRC_IN);
Create a new XML file in your drawable folder called something like custom_progress_bar.xml
and paste this there:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
<clip>
<shape>
<solid android:color="#000000" />
</shape>
</clip>
</item>
<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="#FFFFFF" />
</shape>
</clip>
</item>
</layer-list>
And in your <ProgressBar>
add this attribute:
android:progressDrawable="@drawable/custom_progress_bar"
Change the 2 colors to your own preference. I put #FFFFFF
and #000000
which are white and black.
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