Reputation: 2703
I want to change the color of my ProgressBar
throughout my entire app. The Android documentation indicates that if I am using AppCompat
, it will use the colorAccent
for the color of the progress bars. But it's not using it in my app. Here is my styles.xml
:
<resources>
<!-- Application theme -->
<style name="AppTheme" parent="AppTheme.Base">
</style>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppTheme.Base" parent="Theme.AppCompat">
<item name="android:colorPrimary">@color/colorPrimary</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorAccent">@color/colorAccent</item>
<item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">true</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowBackground">@color/white</item>
<item name="android:windowFullscreen">false</item>
<item name="android:textCursorDrawable">@null</item>
</style>
<style name="AppTheme.Login" parent="AppTheme.Base">
<item name="android:colorControlNormal">@color/gray</item>
<item name="android:colorControlActivated">@color/colorPrimary</item>
<item name="android:colorControlHighlight">@color/med_gray</item>
<item name="android:statusBarColor">@color/dark_gray</item>
</style>
<style name="AppTheme.Menu" parent="AppTheme.Base">
<item name="android:colorPrimary">@color/black</item>
</style>
<style name="AppTheme.Splash" parent="AppTheme.Base">
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
</style>
<style name="login_button_style">
<item name="android:textSize">@dimen/text_small</item>
<item name="android:textAllCaps">false</item>
</style>
</resources>
Upvotes: 0
Views: 1686
Reputation: 1399
If the suggestion given by @RuslanMatveev as a comment doesn't work, you can try the following.
<style name="MyProgressBar" parent="@style/Widget.AppCompat.ProgressBar">
<item name="android:progressBackgroundTint">@color/colorAccent</item>
<item name="android:progressTint">@color/colorAccent</item>
</style>
and then set the following paraments inside your AppTheme.Base
<item name="android:progressBarStyleHorizontal">@style/MyProgressBar</item>
or
<item name="android:progressBarStyle">@style/MyProgressBar</item
UPDATE
In case the solution above change the shape of your progress bar you can try to just add the following line to your AppTheme.base
<item name="colorControlActivated">@color/accent</item>
Upvotes: 2
Reputation: 1024
progress
in your drawable
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1"
android:toDegrees="360" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="15"
android:useLevel="false" >
<size
android:height="48dip"
android:width="48dip" />
<gradient
android:centerColor="@android:color/white"
android:centerY="0.50"
android:endColor="@color/colorYellow"
android:startColor="@color/colorYellow"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
progress
to change your color of progressbar
by using this<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:indeterminateDrawable="@drawable/progress" >
</ProgressBar>
Upvotes: 1