Reputation: 333
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! :)
Upvotes: 19
Views: 36539
Reputation: 1114
set theme in style.xml like this
<style name="ProgressBar" parent="Widget.AppCompat.ProgressBar">
<item name="colorAccent">@color/dark_blue</item>
</style>
then use this style as "theme" in progressBar like this,
<ProgressBar
android:id="@+id/progressBar"
android:theme="@style/ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="440dp"
app:layout_constraintEnd_toEndOf="@+id/splashTitle"
app:layout_constraintHorizontal_bias="0.493"
app:layout_constraintStart_toStartOf="@+id/splashTitle"
app:layout_constraintTop_toBottomOf="@+id/splashTitle" />
Happy coding
Upvotes: 1
Reputation: 180
If android:indeterminateTint
doesn't work, try this:
<ProgressBar
android:id="@+id/progress_bar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:progressTint="@color/Red" <--------------------------
android:progressBackgroundTint="@color/Blue" <---------------
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" />
Upvotes: 3
Reputation: 1869
For future references:
For API 21+ we can use directly in the XML:
android:indeterminateTint="@android:color/white"
Upvotes: 4
Reputation: 7479
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.
Upvotes: 13
Reputation: 924
If you want to change the ProgressBar color, not by drawable, you can use this style as theme for the ProgressBar
<style name="ProgressBar" parent="Widget.AppCompat.ProgressBar">
<item name="colorAccent">@color/white_primary</item>
</style>
Upvotes: 5
Reputation: 433
Go to your styles.xml and change the colorAccent value from your base application theme e.g.
<item name="colorAccent">{COLOR}</item>
I am using minSdkVersion 15 and it worked for me.
Upvotes: 6
Reputation: 3486
Try this and add you custom color
Progressbar mBar= (ProgressBar) findViewById(R.id.spinner);
mBar.getIndeterminateDrawable().setColorFilter(Color.parseColor("#80DAEB"),
android.graphics.PorterDuff.Mode.MULTIPLY);
Hope this helps
Upvotes: 2
Reputation: 1736
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);
Upvotes: 56