2016-04-15 2 views
1

Я не могу понять, как изменить цвет по умолчанию моего кругового индикатора выполнения. Я попытался изменить атрибуты startColor и endcolor под моим тегом gradient в нижнем заголовке файла xml round_progress_view.xml, который является флуоресцентным зеленым цветом, но цвет по умолчанию пурпурного цвета по-прежнему отображается. Пожалуйста, смотрите как мой макет XML-файл (main.xml) и circular_progress_view.xml файл нижеAndroid: Как изменить пользовательский цвет на круговой индикатор выполнения

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> 

ответ

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, как это (обратите внимание андроида: 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" /> 
Смежные вопросы