2013-10-04 16 views
0

我想覆蓋progressBarStyle。在我的應用程序的默認主題是覆蓋ProgressBarStyle

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

,但我需要改變只有一個進度條樣式

android:Theme.NoTitleBar 

我已經嘗試定製風格:

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

,但得到

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

我必須使用系統默認的進度條,在

Theme.NoTitleBar 
+0

也許這將幫助,如果你告訴* *什麼錯誤你知道的。 – Geobits

+0

'出錯了.'。更具體一點不會傷害 – njzk2

回答

1

讓這一個繪製在RES /繪製/ 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> 

,併爲您的進度

android:indeterminateDrawable"@drawable/green_progress" 

或者對於非圓形進度條使用此:

<?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> 

併爲你的進步:下面

android:progressDrawable="@drawable/myprogrogress" 
+0

關閉,但我必須使用系統默認的進度圈,只是在'android:Theme.NoTitleBar'上的其他顏色 – Mariusz

+0

請使用此方法!它會改變你的prgress圈的顏色! –

+0

這是可以接受的,但不要關閉我的話題,因爲我沒有得到我需要的答案 – Mariusz

1

用它來改變你的風格:

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

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

</style> 
+1

'錯誤:錯誤:找不到與給定名稱相匹配的資源('android:indeterminateDrawable'值爲'@ drawable/progress_small_holo'嘗試沒有holo,但同樣的錯誤 – Mariusz

+0

我發佈我的代碼親愛的。你可以使用你自己的drawable。 –

+0

咋就這點我親愛的,我應該使用什麼drawable – Mariusz