这里的进度条指的是圆形进度条。
老是提些各种需求问题,我觉得系统默认的颜色挺好的,但是Pk不过,谁叫我们不是需求人员呢,改吧!
这个没法了只能看源码了,eclipse安装目录:E:\android\android-sdk_r06-windows\android-sdk-windows\platforms\android-xx\data\res 下应有尽有,修改进度条颜色只能找progress ,因为是改变样式,首先找styles.xml
找到xml后,进去找到:<style name="Widget.ProgressBar"> <item name="android:indeterminateOnly">true</item> <item name="android:indeterminateDrawable">@android:drawable/progress_medium_white</item> <item name="android:indeterminateBehavior">repeat</item> <item name="android:indeterminateDuration">3500</item> <item name="android:minWidth">48dip</item> <item name="android:maxWidth">48dip</item> <item name="android:minHeight">48dip</item> <item name="android:maxHeight">48dip</item> <item name="android:mirrorForRtl">false</item>这是那个默认转圈的,但今天我们不修改这个,我们是要改变holo转圈的,所以找到:
<style name="Widget.Holo.ProgressBar.Large" parent="Widget.ProgressBar.Large"> <item name="android:indeterminateDrawable">@android:drawable/progress_large_holo</item> </style>
<?xml version="1.0" encoding="UTF-8"?> <!-- Copyright 2010, The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> -<item> <rotate android:toDegrees="1080" android:fromDegrees="0" android:pivotY="50%" android:pivotX="50%" android:drawable="@drawable/spinner_76_outer_holo"/> </item> -<item> <rotate android:toDegrees="0" android:fromDegrees="720" android:pivotY="50%" android:pivotX="50%" android:drawable="@drawable/spinner_76_inner_holo"/> </item> </layer-list>
即
这两张。
所以只要替换这两张图片,就可以改变颜色了。
完整代码:
<ProgressBar android:id="@+id/loading_progress" style="?android:attr/progressBarStyleLarge" android:layout_width="150px" android:layout_height="150px" android:indeterminate="false" android:indeterminateDrawable="@drawable/progress_bar_color"/>
progress_bar_color.xml:
<?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <rotate android:toDegrees="1080" android:fromDegrees="0" android:pivotY="50%" android:pivotX="50%" android:drawable="@drawable/spinner_76_outer_holo"/> </item> <item> <rotate android:toDegrees="0" android:fromDegrees="720" android:pivotY="50%" android:pivotX="50%" android:drawable="@drawable/spinner_76_inner_holo"/> </item> </layer-list>
spinner_76_inner_holo.xml:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadiusRatio="3" android:shape="ring" android:thicknessRatio="8" android:useLevel="false" > <gradient android:endColor="#800000ba" android:startColor="#8000003d" android:type="sweep" android:useLevel="false" /> </shape>
spinner_76_outer_holo.xml:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadiusRatio="3" android:shape="ring" android:thicknessRatio="8" android:useLevel="false" > <gradient android:endColor="#000000ff" android:startColor="#ff0000ff" android:type="sweep" android:useLevel="false" /> </shape>
最后比较一下效果:
改之前:
改之后: