gpt4 book ai didi

android - 致命异常 : android. view.InflateException:二进制 XML 文件行 #20

转载 作者:行者123 更新时间:2023-11-29 14:36:04 25 4
gpt4 key购买 nike

我是 android 开发的新手。我知道在堆栈溢出中有很多这样的问题。我提到了这些问题,但我还没有得到解决方案。每当我长按 TextInputLayout 应用程序内部的 EditText 时就会崩溃。

Fatal Exception: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class TextView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.view.View.inflate(View.java:19805)
at android.widget.Editor.getTextThumbnailBuilder(Editor.java:2112)
at android.widget.Editor.performLongClick(Editor.java:1014)
at android.widget.TextView.performLongClick(TextView.java:9240)
at android.view.View$CheckForLongPress.run(View.java:21142)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by android.view.InflateException: Binary XML file line #20: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.view.View.inflate(View.java:19805)
at android.widget.Editor.getTextThumbnailBuilder(Editor.java:2112)
at android.widget.Editor.performLongClick(Editor.java:1014)
at android.widget.TextView.performLongClick(TextView.java:9240)
at android.view.View$CheckForLongPress.run(View.java:21142)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by java.lang.UnsupportedOperationException: Failed to resolve attribute at index 24: TypedValue{t=0x3/d=0x285 "res/color/primary_text_material_light.xml" a=1 r=0x106010a}
at android.content.res.TypedArray.getColor(TypedArray.java:447)
at android.widget.TextView.<init>(TextView.java:738)
at android.widget.TextView.<init>(TextView.java:671)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:56)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:972)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1031)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.view.View.inflate(View.java:19805)
at android.widget.Editor.getTextThumbnailBuilder(Editor.java:2112)
at android.widget.Editor.performLongClick(Editor.java:1014)
at android.widget.TextView.performLongClick(TextView.java:9240)
at android.view.View$CheckForLongPress.run(View.java:21142)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by android.view.InflateException
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:782)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:618)
Caused by java.lang.UnsupportedOperationException
android.content.res.TypedArray.getColor (TypedArray.java:447)
android.widget.TextView.<init> (TextView.java:738)
android.widget.TextView.<init> (TextView.java:671)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:618)

我的 XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/sign_in_relative_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sign_in_bg"
class = "com.fitficfitz.android.ui.login.SignInFragment">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="@color/colorPrimary"
android:paddingLeft="@dimen/size_5"
>
<ImageView
android:id="@+id/backButton"
android:layout_width="@dimen/size_20"
android:layout_height="@dimen/size_20"
android:layout_marginLeft="@dimen/size_10"
android:src="@drawable/back_btn"/>
<TextView
android:id="@+id/more_session_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SIGN IN"
android:textStyle="normal"
android:textSize="24sp"
android:textColor="@color/white"
android:paddingLeft="@dimen/size_30"
/>
<include
android:id="@+id/book_toolbar"
layout="@layout/book_session_toolbar"/>
</LinearLayout>

<LinearLayout
android:id="@+id/social_sign_in_linear_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/size_126"
android:orientation="horizontal"
android:layout_marginTop="@dimen/size_50">

<FrameLayout
android:id="@+id/twitter_sign_in"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="@dimen/weight_1"
android:visibility="gone">

<TextView
android:id="@+id/twitter_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="@dimen/size_10"
android:drawableTop="@drawable/twitter"
android:gravity="center"
android:letterSpacing="@dimen/letter_spacing_040"
android:text="@string/login_with_twitter"
android:textColor="@color/white"
android:textSize="@dimen/font_13"
tools:ignore="UnusedAttribute"/>
</FrameLayout>

<View
android:id="@+id/social_divider_view"
android:layout_width="@dimen/size_1"
android:layout_height="@dimen/size_126"
android:alpha="0.2"
android:visibility="gone"
android:background="@color/grey_eff6fc"/>

<FrameLayout
android:id="@+id/facebook_sign_in"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="@dimen/weight_1">

<TextView
android:id="@+id/facebook_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="@dimen/size_10"
android:drawableTop="@drawable/facebook"
android:gravity="center"
android:letterSpacing="@dimen/letter_spacing_040"
android:text="@string/login_in_with_facebook"
android:textColor="@color/white"
android:textSize="@dimen/font_13"
tools:ignore="UnusedAttribute"/>
</FrameLayout>
</LinearLayout>

<View
android:id="@+id/social_horizontal_divider_view"
android:layout_width="match_parent"
android:layout_height="@dimen/size_1"
android:layout_below="@+id/social_sign_in_linear_layout"
android:layout_marginBottom="@dimen/size_50"
android:alpha="0.2"
android:background="@color/grey_eff6fc"/>

<ImageView
android:id="@+id/username_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/social_horizontal_divider_view"
android:layout_marginBottom="@dimen/size_20"
android:layout_marginLeft="@dimen/size_28"
android:layout_marginRight="@dimen/size_28"
android:contentDescription="@null"
android:src="@drawable/username"
android:layout_marginTop="@dimen/size_25"/>
<android.support.design.widget.TextInputLayout
android:theme="@style/TextLabel"
android:id="@+id/input_layout_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/username_image_view"
android:layout_toRightOf="@id/username_image_view"
android:layout_marginTop="@dimen/size_10"
android:layout_below="@+id/social_horizontal_divider_view">
<EditText
android:layout_marginTop="10dp"
android:id="@+id/username_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="Email Address"
android:inputType="textEmailAddress"
android:paddingBottom="@dimen/size_16"
android:translationY="10dp"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="@dimen/font_13"/>
</android.support.design.widget.TextInputLayout>


<View
android:id="@+id/username_base_view"
android:layout_width="wrap_content"
android:layout_height="@dimen/size_1"
android:layout_alignLeft="@id/input_layout_username"
android:layout_alignParentRight="true"
android:layout_below="@id/input_layout_username"
android:alpha="0.2"
android:background="@color/grey_eff6fc"
android:paddingBottom="@dimen/size_10"/>

<ImageView
android:id="@+id/password_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/username_base_view"
android:layout_marginTop="@dimen/size_30"
android:contentDescription="@null"
android:paddingBottom="@dimen/size_20"
android:paddingLeft="@dimen/size_28"
android:paddingRight="@dimen/size_28"
android:src="@drawable/password"
/>
<android.support.design.widget.TextInputLayout
android:theme="@style/TextLabel"
android:id="@+id/input_layout_passwrod"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/username_base_view"
android:layout_toEndOf="@id/password_image_view"
android:layout_marginTop="@dimen/size_10"
android:layout_toRightOf="@id/password_image_view">
<EditText
android:id="@+id/password_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:hint="@string/password"
android:inputType="textPassword"
android:paddingBottom="@dimen/size_16"
android:paddingTop="@dimen/size_10"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="@dimen/font_13"
/>
</android.support.design.widget.TextInputLayout>

<ImageView
android:id="@+id/forgot_password_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/username_base_view"
android:layout_marginEnd="@dimen/size_20"
android:layout_marginRight="@dimen/size_20"
android:layout_marginTop="@dimen/size_30"
android:clickable="true"
android:src="@drawable/forgot_password"/>

<View
android:id="@+id/password_base_view"
android:layout_width="wrap_content"
android:layout_height="@dimen/size_1"
android:layout_alignLeft="@id/input_layout_passwrod"
android:layout_alignParentRight="true"
android:layout_below="@id/input_layout_passwrod"
android:alpha="0.2"
android:background="@color/grey_eff6fc"/>

<Button
android:id="@+id/sign_in_button"
style="@style/EndButtonStyle"
android:layout_alignParentBottom="true"
android:layout_marginTop="@dimen/size_32"
android:text="@string/sign_in_button"/>

<LinearLayout
android:id="@+id/sign_up_linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/sign_in_button"
android:gravity="center_horizontal"
android:orientation="horizontal">

<TextView
android:id="@+id/sign_up_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sign_up_text"
android:textColor="@color/grey_a8a9ab"
android:textSize="@dimen/font_13"/>

<TextView
android:id="@+id/sign_up_question_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_4"
android:clickable="true"
android:text="@string/sign_up_question"
android:textColor="@color/grey_a8a9ab"
android:textSize="@dimen/font_14"/>
</LinearLayout>

<FrameLayout
android:id="@+id/login_progress_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="@dimen/alpha_04"
android:background="@color/black"
android:clickable="true"
android:focusable="true"
android:visibility="gone">

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
</RelativeLayout>

primary_text_material_light.xml 代码:

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/primary_text_disabled_material_light"/>
<item android:color="@color/primary_text_default_material_light"/>
</selector>

样式/TextLabel 代码:

<style name="TextLabel" parent="TextAppearance.AppCompat">
<item name="android:textColorHint">@color/white</item>
<item name="colorAccent">@color/white</item>
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/white</item>
</style>

最佳答案

我花了几个小时后发现了这个问题。问题是我错过了在我的 style 中为 TextInputLayout 添加 textColorHighlight。所以,我改变了我的 theme

<style name="TextLabel" parent="TextAppearance.AppCompat">
<item name="android:textColorHint">@color/white</item>
<item name="colorAccent">@color/white</item>
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/white</item>
</style>

<style name="TextLabel" parent="@android:style/TextAppearance.Widget.TextView">
<item name="android:textColorHint">@color/white</item>
<item name="colorAccent">@color/white</item>
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/white</item>
<item name="android:textColorHighlight">@color/grey_5f6971</item>
<item name="android:textColorLink">@color/white</item>
</style>

感谢在评论和回答部分帮助我的人。

关于android - 致命异常 : android. view.InflateException:二进制 XML 文件行 #20,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39609740/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com