2010-12-29 9 views
7

가로 진행 바의 색상을 변경하려하지만 변경되지 않았습니다. 나는 약간의 인터넷 검색을했고, ur 사이트에서 주어진 약간의 예를지나 갔다. 그러나 나는 색깔을 정확하게 바꾸기 위해 성공하지 못하고있다. progressBar.setProgressDrawable(Drawable d)을 사용했지만 바 자체의 배경색 만 설정하는 대신 전체 진행률 막대보기의 배경색을 설정합니다.안드로이드의 진행 바 색상 변경

몸도 좀 도와주세요.

감사합니다.

답변

0
You Can create custom_progress.xml file in drawable folder - 
<rotate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" 
    android:toDegrees="360"> 
    <shape android:shape="ring" android:innerRadiusRatio="2" 
     android:thicknessRatio="6" android:useLevel="false"> 

     <size android:width="76dip" android:height="76dip" /> 
     <gradient android:type="sweep" android:useLevel="false" 
      android:startColor="#c76a37" 
      android:endColor="#A4B4B9" 
      /> 
    </shape> 
</rotate> 

//And add below code to your layout file to create progress bar 
<ProgressBar 
     android:id="@+id/progressBar1" 
     style="?android:attr/progressBarStyleHorizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_marginTop="68dp" 
     android:progressDrawable="@drawable/custom_progress" 
     /> 
Hope this will help you. 
1

안녕하세요, 저는이 프로젝트에서이 코드를 사용하고 있습니다. 나는 그것이 당신을 위해 일하기를 바랍니다.

// 레이아웃 파일에 ProgressBar를 만듭니다.

<ProgressBar 
    android:id="@+id/yourid" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:progressDrawable="@drawable/slider" 
      /> 

// 이름 슬라이더를 사용하여 드로어 블 폴더에 .xml 파일을 만듭니다.

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 

    <item 
     android:id="@android:id/background" 
     android:drawable="@drawable/grey_bar_music"/> 
    <item android:id="@android:id/progress"> 
     <clip android:drawable="@drawable/blue_bar_music" /> 
    </item> 
</layer-list> 

//grey_bar_music ->Background image name for your progressbar. 
//blue_bar_music->Progress bar change color using this image when it start from 0.