问题描述
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/Black"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/buttonFoo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawableStart="@drawable/ic_foo_icon"
android:drawablePadding="8dp"
android:text="@string/foo" />
/androidx.appcompat.widget.LinearLayoutCompat>
上述Activity布局在Android 4.4上启动Activity时会导致如下异常:
android.view.InflateException: Binary XML file line #123: Error inflating class <unkNown>
它仅在 Android 4.4 上发生。所有其他设备都很好。
如果删除以下内容,一切都会好起来的:
android:drawableStart="@drawable/ic_foo_icon"
android 4.4 是否支持androidx.appcompat.widget.AppCompatButton 中的android:drawableStart?
解决方法
为什么不使用 drawableLeft / drawableRight 来代替?