如何使用指标图像制作自定义进度条,如whatsapp?

Cab*_*zas 3 android android-progressbar whatsapp

我在res-> drawable文件夹中创建了一个名为customprogressbar.xml的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="#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>
Run Code Online (Sandbox Code Playgroud)

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleHorizontal"
    android:progressDrawable="@drawable/custom_progressbar"         
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)

现在我有颜色,但我需要在填充和保持之间放置指示图像.

在此输入图像描述

任何的想法?

Nic*_*oso 6

您所看到的是Seekbar而不是简单的Progressbar.圆形指示器称为拇指,您可以添加任何您喜欢的图像(以及自定义进度条).

<SeekBar ...
    android:thumb="@drawable/your_thumb"
    android:progressDrawable="@drawable/progress_bar_layers"
 />
Run Code Online (Sandbox Code Playgroud)

  • 非常感谢你.那很完美.我必须自定义seekBar http://stackoverflow.com/questions/16163215/android-styling-seek-bar (2认同)