这个形状出现在 Android Studio 上
但当它在手机上运行时,它看起来像这样
这是我的代码
在 XML 中
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:max="10000"
android:progress="500"
android:progressDrawable="@drawable/custom_seekbar"
android:thumb="@drawable/thumb_transperent"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
其中@drawable/custom_seekbar
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
<rotate>
<layer-list>
<item android:drawable="@drawable/progress_bar"/>
</layer-list>
</rotate>
</item>
<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
<clip>
<layer-list>
<item android:drawable="@drawable/progressbar_progress"/>
</layer-list>
</clip>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
和@drawable/progress_bar
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:top="15dp">
<shape android:shape="line">
<stroke …Run Code Online (Sandbox Code Playgroud)