2016-02-23 75 views
3

我创建了一个名为customprogressbar.xml的XML文件在你的水库>绘制文件夹:如何使指标图像自定义进度栏,如whatsapp?

<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="#000001" 
       android:centerColor="#0b131e" 
       android:centerY="1.0" 
       android:endColor="#0d1522" 
       android:angle="270" 
     /> 
    </shape> 
    </item> 

    <!-- Define the progress properties like start color, end color etc --> 
    <item android:id="@android:id/progress"> 
    <clip> 
     <shape> 
      <gradient 
       android:startColor="#007A00" 
       android:centerColor="#007A00" 
       android:centerY="1.0" 
       android:endColor="#06101d" 
       android:angle="270" 
      /> 
     </shape> 
    </clip> 
    </item> 
</layer-list> 

而且

<ProgressBar 
    android:id="@+id/progressBar1" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:progressDrawable="@drawable/custom_progressbar"   
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

现在我有颜色,但我需要把指示器图像,在填充物之间并保持。

enter image description here

任何想法?

+0

你究竟是什么考虑指标图像是?哪个指标为什么? –

+0

如果您看到屏幕截图,您可以在填充和保留之间看到一个点。 – Cabezas

回答

6

你在看什么是一个Seekbar而不是一个普通的Progressbar。圆圈指示器称为拇指,您可以添加任何您喜欢的图像(以及自定义进度条)。

<SeekBar ... 
    android:thumb="@drawable/your_thumb" 
    android:progressDrawable="@drawable/progress_bar_layers" 
/> 
+2

非常感谢。那很完美。我必须做一个自定义seekBar http://stackoverflow.com/questions/16163215/android-styling-seek-bar – Cabezas

0

如果“指示器图像”指的是圆头圆那里,那么我不知道这是否可以与进度完成。

这看起来更像SeekBar,然后是ProgressBar。除了SeekBar具有“拇指”属性外,它们几乎相同。这可以为你工作:

<SeekBar 
    android:id="@+id/seekBar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:thumb="@drawable/thumb_image" 
    android:progressDrawable="@drawable/customprogressbar.xml" 
/>