带图标的水平进度条

Horizontal progress bar with icon

在我的项目中我想做一个类似于下面的水平进度条。

我已经尝试了很多库,但是 none 其中有这个功能。有什么办法可以做到这一点?

这是我的代码:

dialog = new ProgressDialog(Context.this);
dialog.setIndeterminate(true);
dialog.setMessage("Some Text");
dialog.show();

您应该使用 seekBar 而不是 progressDialog。您可以添加 android:thumb 图标。

<SeekBar
    android:id="@+id/seekBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:thumb="@drawable/icon"
    android:max="10"
    android:progress="5"
    android:progressDrawable="@drawable/custom_seekbar" />

自定义-seekbar.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/progress">
        <clip>
            <shape android:shape="rectangle">
                <size
                    android:width="12dp"
                    android:height="12dp" />
                <corners android:radius="15dp" />

                <solid android:color="#4fc3f7" />

                <gradient
                    android:angle="270"
                    android:centerColor="#4fc3f7"
                    android:endColor="#4fc3f7"
                    android:startColor="#4fc3f7" />
            </shape>
        </clip>
    </item>
</layer-list>