【发布时间】:2017-11-15 16:53:22
【问题描述】:
这是我需要用xml drawable 为SeekBar 实现的目标:
我尝试了许多不同的变化,这是我能做到的最好的。
这是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 上的结果: 问题是线条不是垂直居中的。
API 24 上的结果: 这显示正是我希望它显示的方式。
是否有任何可能的解决方案可以使其在来自API 16 的所有设备上显示为第一张图片?
我不想使用九色补丁,因为我需要使用资源中的颜色。
我试过padding,gravity,top,bottom,inter-shape,line,rectangle,但我找不到解决方案...
【问题讨论】:
标签: android drawable android-drawable