2010-12-29 36 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. 
関連する問題