【问题标题】:Strange custom SeekBar drawable behavior on different APIs不同 API 上的奇怪自定义 SeekBar 可绘制行为
【发布时间】:2023-03-21 15:24:01
【问题描述】:

在运行 Android API

在运行 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" />

【问题讨论】:

    标签: android android-drawable android-seekbar android-api-levels


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多