我无法弄清楚如何更改循环进度条的默认颜色。我尝试在下面的xml文件标题circular_progress_view.xml中更改我的渐变标记下的startColor和endcolor属性,这是一种荧光绿色,但洋红色的默认颜色仍然显示。请查看我的布局xml文件(main.xml)和下面的circular_progress_view.xml文件
main.xml中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">
<LinearLayout
android:id="@+id/linlaHeaderProgress"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" >
<ProgressBar
android:indeterminate="true"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:progressDrawable="@drawable/circular_progress_view">
</ProgressBar>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listview"
android:layout_weight="1">
</ListView>
<Button
android:id="@+id/btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Submit"/>
</LinearLayout>
circular_progress_view.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="7.0">
<gradient
android:angle="0"
android:type="sweep"
android:useLevel="false"
android:startColor="#00FF00"
android:endColor="#00FF00"/>
</shape>
</rotate>
答案 0 :(得分:1)
我这样做并且工作得很好
<?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="1080" >
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="12"
android:useLevel="false" >
<size
android:height="76dp"
android:width="76dp" />
<gradient
android:angle="0"
android:endColor="@color/progress_bar_color"
android:startColor="@android:color/transparent"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
并将其添加到res / values / colors.xml
<color name="progress_bar_color">#00ff00</color>
我像这样添加ProgressBar(注意 android:indeterminateDrawable ):
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:indeterminate="true"
android:indeterminateDrawable="@drawable/progress_bar"
style="?android:attr/progressBarStyleLargeInverse" />