这是我需要使用
我尝试了许多不同的变化,这是我能做到的最好的。
这是
这里是
API 24的结果:
这正好显示我想要的样子。
有没有可能的解决方案,可以让所有来自
xml
drawable
来实现SeekBar
的效果:
![enter image description here](https://istack.dev59.com/vCfQX.webp)
这是
seekbar_thumb_drawable.xml
:<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="@color/accent_color"/>
<size
android:height="20dp"
android:width="20dp" />
</shape>
这里是
seekbar_drawable.xml
文件的内容:<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@android:id/background"
android:height="5dp"
android:top="7.5dp">
<shape
android:shape="rectangle">
<solid android:color="@color/seekbar_background" />
<corners android:radius="2.5dp" />
</shape>
</item>
<item
android:id="@android:id/progress"
android:height="10dp"
android:top="5dp">
<clip>
<shape
android:shape="rectangle">
<solid android:color="@color/seekbar_progress" />
<corners android:radius="5dp" />
</shape>
</clip>
</item>
</layer-list>
API 18的结果:
问题在于线条没有垂直居中。
![enter image description here](https://istack.dev59.com/CK7Pd.webp)
![enter image description here](https://istack.dev59.com/LQRs8.webp)
API 16
的设备都显示为第一张图片的样子?
我不想使用九宫格,因为我需要使用来自资源的颜色。
我尝试了padding
、gravity
、top
、bottom
、inter-shape
、line
、rectangle
,但是我找不到解决方案...