Mariusz
Mariusz

Reputation: 1410

Override ProgressBarStyle

I want to override progressBarStyle. Default theme in my app is

<style name="AppBaseTheme" parent="android:Theme.Light.NoTitleBar">

but I need to change only one progress bar style to

android:Theme.NoTitleBar

I have already tried to customize style:

<style name="DarkTheme" parent="android:Theme.NoTitleBar">
    <item name="android:progressBarStyle">@style/progressBarStyle</item>
</style>

but got

error: Error: No resource found that matches the given name (at 'android:progressBarStyle' with value '@style/progressBarStyle')

i have to use default system progress bar that is in

Theme.NoTitleBar

Upvotes: 1

Views: 1966

Answers (2)

Macrosoft-Dev
Macrosoft-Dev

Reputation: 2185

Use below to change your style:

<style name="IndeterminateProgress" parent="@android:style/Widget.ProgressBar">

<item name="android:indeterminateDrawable">@drawable/progress_small_holo</item>

</style>

Upvotes: 1

A.S.
A.S.

Reputation: 4574

Make this one a drawable in your res/drawable/green_progress.xml

<?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:toDegrees="360" >

    <shape
       android:innerRadiusRatio="5"
        android:shape="ring"
        android:thicknessRatio="15"
        android:useLevel="false" >
        <size
            android:height="48dip"
            android:width="48dip" />

        <gradient
            android:centerColor="#FFFFFF"
            android:centerY="0.50"
            android:endColor="@android:color/transparent"
            android:startColor="#4bd577"
            android:type="sweep"
            android:useLevel="false" />
    </shape>

</rotate>

and for your progressbar

android:indeterminateDrawable"@drawable/green_progress"

Or for a non circular Progressbar use this:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="0dip" />
            <gradient android:startColor="#004676" android:centerColor="#004676"
                android:centerY="0.75" android:endColor="#004676" android:angle="90" />
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="0dip" />
                <gradient android:startColor="#ee7407" android:endColor="#ee7407"
                    android:angle="90" />
            </shape>
        </clip>
    </item>
</layer-list>

And for your Progress:

 android:progressDrawable="@drawable/myprogrogress"

Upvotes: 1

Related Questions