1

在运行 Android API <= 22 的设备上,我的自定义 SeekBar 如下所示: 在此处输入图像描述

在运行 Android API >= 23 的设备上,我的自定义 SeekBar 如下所示: 在此处输入图像描述

为什么我的 SeekBar drawable 在设备 API >= 23 上看起来不正确?这是我的 XML

seekbar_progress.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:drawable="@drawable/seekbar_progress_bg" />
<item android:id="@android:id/progress">
    <scale
        android:drawable="@drawable/seekbar_progress_fill"
        android:scaleWidth="100%" />
</item>

</layer-list>

seekbar_thumb.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="oval">
        <size
            android:width="@dimen/seekbar_thumb"
            android:height="@dimen/seekbar_thumb" />
        <solid android:color="@color/white" />
        <stroke
            android:width="@dimen/seekbar_thumb_border"
            android:color="@color/gray" />
    </shape>
</item>
</layer-list>

布局文件

<SeekBar
    android:thumb="@drawable/seekbar_thumb"
    android:progressDrawable="@drawable/seekbar_progress"
    android:splitTrack="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:progress="50" />
4

1 回答 1

3

由于未知的原因,通过使用 minHeight 和 maxHeight 我能够获得所需的行为

于 2016-10-10T17:50:57.140 回答