【发布时间】:2018-06-16 02:21:54
【问题描述】:
我有以下布局文件
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootConstraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
tools:context="mtronics.alertme.HomePage">
<TextView
android:id="@+id/tvSpeedSet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Limit : 0 Km/h"
android:textAlignment="center"
android:textColor="@color/colorText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/speedView" />
<SeekBar
android:id="@+id/seekBarSpeedSet"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/corner_fillet_background"
android:max="200"
android:progress="0"
android:thumb="@drawable/icon_seek_thumb"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvSpeedSet" >
</SeekBar>
<ListView
android:id="@+id/listAlerts"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:divider="@color/colorTransparent"
android:dividerHeight="8dp"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/seekBarSpeedSet">
</ListView>
</android.support.constraint.ConstraintLayout>
可绘制文件 icon_seek_thumb.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<size
android:height="40dp"
android:width="40dp" />
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item android:drawable="@drawable/ic_seek_thumb"/>
</layer-list>
ic_seek_thumb.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/colorText"
android:pathData="...."/>
</vector>
使用上面的布局,我只收到 API 19 的以下错误,更高版本可以正常工作
注意:如果我从 seekbar 中删除 android:thumb ,它也适用于 API 19
当我尝试在 API 19 中执行时出现以下错误
android.view.InflateException: Binary XML file line #0: Error inflating class SeekBar
【问题讨论】:
标签: java android xml android-layout android-fragments