【发布时间】:2022-02-02 11:16:03
【问题描述】:
我已经厌倦了解决这个问题。总是告诉我这个错误
Binary XML file line #11: Error inflating class EditText.
我不明白如何解决这个问题。已经尝试了许多 StackOverflow 答案,但都失败了。 使用 Gradle 7.1.0 版本。设备 Pixel 4 API 27。
XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/PrimaryLight"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="@+id/etID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_marginRight="15dp"
android:ems="10"
android:gravity="center_horizontal"
android:hint="@string/hint_id"
android:inputType="number"
android:minHeight="48dp"
android:textColorHint="@color/material_dynamic_neutral10"
android:importantForAutofill="no" />
</LinearLayout>
错误信息:
2022-02-02 17:05:04.720 9809-9809/com.example.magicidapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.magicidapplication, PID: 9809
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.magicidapplication/com.example.magicidapplication.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class EditText
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class EditText
Caused by: java.lang.UnsupportedOperationException: Can't convert to ComplexColor: type=0x1
【问题讨论】:
-
你能展示你的Java代码吗?
-
“@color/material_dynamic_neutral10”的值是多少
-
@SiddarthJain #191C1E
-
问题出在这个颜色目标上。首先尝试像这样手动添加它
android:textColorHint="#191C1E" -
@FrancescoD'OnorioDeMeo link
标签: java android android-studio