移动我的进度与图像的android(move my progressbar with an imag

2019-07-29 18:23发布

i have this code

is a progress bar that fill with a red color

<?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>
            <gradient
            android:startColor="#c3c3c3"
                android:centerColor="#c3c3c3"
                android:centerY="0.75"
                android:endColor="#7f7f7f"
                android:angle="270"/>
            <padding android:left="1dp"
            android:top="1dp"
            android:right="1dp"
            android:bottom="1dp"/> 
        <corners android:radius="10dp"/> 
    </shape>
</item>

<item android:id="@android:id/secondaryProgress">
    <clip>
        <shape>
            <gradient
                android:startColor="#234"
                android:centerColor="#234"
                android:centerY="0.75"
                android:endColor="#a24"
                android:angle="270"/>
            <padding android:left="1dp"
                android:top="1dp"
                android:right="1dp"
                android:bottom="1dp"/> 
            <corners android:radius="10dp"/> 
            </shape>
    </clip>
</item>

<item android:id="@android:id/progress">
    <clip>
       <shape>
            <gradient
                android:startColor="#a42c48"
                android:centerColor="#a42c48"
                android:centerY="0.75"
                android:endColor="#eb3e67"
                android:angle="270"/>
            <padding android:left="1dp"
                android:top="1dp"
                android:right="1dp"
                android:bottom="1dp"/> 
            <corners android:radius="10dp"/> 
        </shape>
    </clip>
    </item>
</layer-list>

and look like this

now i want to add an image to move at the same time the progress bar fills up like the image below

please help me

thanks in advance

Answer 1:

也许你可以使用你的layerlist样式搜索条(而不是进度),并添加您的图像作为拇指洗涤?

<SeekBar
    android:id="@+id/seekBar1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:thumb="@drawable/your_android_image"
    android:progressDrawable="@drawable/your_layerlist_drawable"/>


Answer 2:

我觉得这个活动图像可以使用搜索条来完成,这一形象被称为吞绘制

你可以试试这个教程它会帮助你很多!

设置搜索条属性android:thumb="@drawable/seek_thumb"以指向你想要的绘制



文章来源: move my progressbar with an image android