首页 > 解决方案 > 如何在android中实现带有单位增加的虚线进度条

问题描述

我想要这种类型的视图,我检查了 Discrete Seekbar,但它显示了每个步骤的点,即使 Thumb 和 Track 已更改。 低到高仪表

如果我使用带有自定义 Thumb 和 Progress Drawable 的 Seekbar,我无法在使用 ProgressDrawable 附加的虚线上正确设置 Progress,以及如何限制用户拖动 Seekbar。

<!-- dotted.xml -->
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android1="http://schemas.android.com/apk/res/android">
<!--Item background and progress order cannot be reversed-->
<item android:id= "@android:id/background" >
    <shape android:shape= "line" >
        <stroke
            android:width= "10dp"
            android:color= "#E9EAF5"
        android:dashWidth="10dp" android:dashGap="4dp"/>
    </shape>
</item>
</layer-list>

<SeekBar
android:id="@+id/seekBar"
android:layout_width="181dp"
android:layout_height="48dp"
android:enabled="false"
android:progress="6"
android:progressDrawable="@drawable/dotted"
android:thumb="@drawable/circle_progress" />

标签: androidprogress-barandroid-custom-viewseekbar

解决方案


推荐阅读