3
안드로이드

나는 다음과 같은 스타일 코드설정 나머지 진행 표시 줄 색상 <p>내 진행 막대가 나는를 설정하는 방법 이미지</p> <p><img src="https://i.stack.imgur.com/C59Ic.png" alt="enter image description here"> <br> 다음과 같습니다 내 진행률 막대에 표시된 회색 부분의 색상 ???</p>

<item android:id="@android:id/progress"> 
    <clip> 
     <shape> 
     <corners android:radius="0dip" /> 
      <gradient 
      android:angle="0" 
      android:endColor="#36A19C" 
      android:startColor="#36A19C" /> 
     </shape> 
    </clip> 
    </item> 
를 사용하여 진행률 표시 줄의 색상을 설정하고있어에서

답변

4

자습서 herehere을 살펴보십시오.

custom_progressbar.xml을 파일을 생성하여 당김

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 

<!-- Define the background properties like color etc --> 
    <item android:id="@android:id/background"> 
     <shape> 
      <gradient 
        android:startColor="backgroundColor" 
        android:endColor="backgroundColor" 
        android:angle="0" 
      /> 
     </shape> 
    </item> 

<!-- Define the progress properties like start color, end color etc --> 
    <item android:id="@android:id/progress"> 
     <clip> 
      <shape> 
       <gradient 
        android:startColor="progressColor" 
        android:endColor="progressColor" 
        android:angle="0" 
       /> 
      </shape> 
     </clip> 
    </item> 

</layer-list> 

// Get the Drawable custom_progressbar      
Drawable customDrawable= res.getDrawable(R.drawable.custom_progressbar); 
// set the drawable as progress drawavle 
progressBar.setProgressDrawable(customDrawable); 
+0

고마워요 ... 성공했습니다 ... – prince

+0

왜 진도 표시기 높이가 그렇게 커지나요? 그것을 더 짧게 만드는 방법? –

2

당신은이 방법으로 시도 할 수있는 코드에서의 ProgressBar로 설정 :

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

    <item android:id="@android:id/background"> 
     <shape> 
      <solid android:color="@color/seekbar_background" /> 

      <stroke 
       android:width="@dimen/seekbar_background_border" 
       android:color="@android:color/transparent" /> 
     </shape> 
    </item> 
    <item android:id="@android:id/progress"> 
     <clip> 
      <shape> 
       <solid android:color="@color/seekbar_progress" /> 
      </shape> 
     </clip> 
    </item> 

</layer-list> 

진행 표시 줄을 여러 레이어를 보유하는 레이어 목록을 사용합니다. 에스. 배경이이고 진행이 필요합니다. 희망이 당신을 도와줍니다 :)

0

이 코드 줄을 진행률 표시 줄 XML에 추가하십시오.

android:progressBackgroundTint="#ReplaceThisWithYourColor" 

저에게 적합합니다.