Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't change colorAccent from my application's theme

I've been trying to change the color of the progressBar, and i've noticed it's using the accentColor (which is Blue in my case) and i've been trying to change it without luck.

Am I missing something?

This is in my styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="searchViewStyle">@style/AppTheme.SearchView</item>
    <item name="editTextColor">@android:color/white</item>
    <item name="actionBarStyle">@style/AppTheme.ActionBarStyle</item>
    <item name="actionOverflowButtonStyle">@style/AppTheme.OverFlowItem</item>
    <item name="colorPrimary">@color/ColorPrimary</item>
    <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
    <item name="colorAccent">@color/ColorPrimaryDark</item>
</style>

This is my element in the layout.xml

<ProgressBar
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    style="@style/Widget.AppCompat.ProgressBar"
    android:id="@+id/progressBar01"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:indeterminate="true"/>

My activity:

public class MainActivity extends android.support.v7.app.AppCompatActivity
like image 818
Computer's Guy Avatar asked Oct 19 '22 15:10

Computer's Guy


1 Answers

If you want to change accent color for one specific view you need to create style own style and set it to the view using android:theme attribute.

UPDATED

<style name="CustomProgressBarTheme" parent="Widget.AppCompat.ProgressBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimaryCutom</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDarkCustom</item>
    <item name="colorAccent">@color/colorAccentCustom</item>
</style>


<ProgressBar
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:theme="@style/CustomProgressBarTheme"
android:id="@+id/progressBar01"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:indeterminate="true"/>
like image 91
Volodymyr Avatar answered Oct 22 '22 01:10

Volodymyr