当前位置: 首页 > 知识库问答 >
问题:

在Android 4.4.2上创建TextInputLayout时inflating类EditText错误:

巴博耘
2023-03-14
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<include android:id="@+id/loginInfiLogoRL"
    layout="@layout/login_infi_logo_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingLeft="-3dp"
    android:layout_marginTop="5dp"
    android:layout_marginBottom="10dp"/>

<!--EMAIL-->
<android.support.design.widget.TextInputLayout
    android:id="@+id/email_wrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/loginInfiLogoRL"
    android:theme="@style/TextLabel">

    <EditText
        android:id="@+id/etUserName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/login_screen_email_hint"
        android:imeOptions="actionNext"
        android:inputType="textEmailAddress"
        android:maxLines="1"
        android:nextFocusDown="@+id/etPassword"
        android:singleLine="true"
        android:textColor="@android:color/white"
        android:textColorHighlight="@color/Orange"
        android:textColorHint="@android:color/white" />

</android.support.design.widget.TextInputLayout>


<RelativeLayout
    android:id="@+id/rlPassword"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="12dp"
    android:layout_below="@id/email_wrapper">

    <!--PASSWORD-->
    <android.support.design.widget.TextInputLayout
        android:id="@+id/password_wrapper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/TextLabel">

        <EditText
            android:id="@+id/etPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/login_screen_password_hint"
            android:imeOptions="actionNext"
            android:inputType="textPassword"
            android:maxLines="1"
            android:nextFocusDown="@+id/bSignIn"
            android:shadowColor="@color/Orange"
            android:singleLine="true"
            android:textColor="@android:color/white"
            android:textColorHint="@android:color/white" />

    </android.support.design.widget.TextInputLayout>

    <!--FORGOT-->
    <TextView
        android:id="@+id/tvForgotPassword"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_centerInParent="true"
        android:paddingBottom="14dp"
        android:paddingRight="10dp"
        android:text="@string/login_screen_forgot_password_text"
        android:textColor="@color/Orange"
        android:textSize="16sp" />

</RelativeLayout>

<TextView
    android:id="@+id/tvRememberMe"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="invisible" />


<!--Buttons Login and SignUp-->
<LinearLayout
    android:id="@+id/llSignUp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="15dp"
    android:layout_marginTop="10dp"
    android:gravity="center_vertical"
    android:layout_below="@+id/rlPassword">

    <!--Sign up Button-->
    <TextView
        android:id="@+id/bSignUp"
        android:layout_width="0dp"
        android:layout_height="40dp"
        android:layout_marginRight="16dp"
        android:layout_weight="1"
        android:textSize="18sp"
        android:gravity="center"
        android:imeOptions="actionGo"
        android:text="@string/login_screen_sign_up_button_text"
        android:textColor="@color/Orange" />

    <!--Login Button-->
    <Button
        android:id="@+id/bSignIn"
        android:layout_width="0dp"
        android:layout_height="40dp"
        android:layout_marginLeft="16dp"
        android:layout_weight="1"
        android:background="@drawable/fragment_first_use_cloud_get_started_button_background"
        android:focusable="true"
        android:imeOptions="actionGo"
        android:text="@string/login_screen_sign_in_button_text"
        android:textColor="@color/Orange" />

</LinearLayout>

<LinearLayout
    android:id="@+id/llFacebook"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="15dp"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/llSignUp"
    android:gravity="right">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginRight="8dp"
        android:gravity="center"
        android:text="@string/log_in_with_facebook"
        android:textAppearance="@style/TextAppearance.AppCompat.Small.Inverse"
        android:textColor="@android:color/white" />

    <com.facebook.login.widget.LoginButton
        android:id="@+id/bFacebookLogin"
        android:layout_width="@dimen/circular_images_size_l"
        android:layout_height="@dimen/circular_images_size_l"
        android:background="@drawable/btnfbconnect"
        android:text=""
        android:textColor="@android:color/white"/>

</LinearLayout>


<!--Privacy-->
<ImageView
    android:id="@+id/ivLockImage"
    android:layout_width="@dimen/circular_images_size_l"
    android:layout_height="@dimen/circular_images_size_l"
    android:layout_alignParentLeft="true"
    android:layout_below="@id/llFacebook"
    android:layout_marginTop="18dp"
    android:src="@drawable/iconshieldprivacy" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignEnd="@+id/llSignUp"
    android:layout_alignParentRight="@+id/ivLockImage"
    android:layout_alignRight="@+id/llSignUp"
    android:layout_alignTop="@+id/ivLockImage"
    android:layout_toRightOf="@+id/ivLockImage"
    android:text="@string/login_screen_infi_privacy_title"
    android:textColor="@android:color/white"
    android:textSize="12sp"
    android:textStyle="bold" />

<TextView
    android:id="@+id/text1"
    android:layout_width="241dp"
    android:layout_height="wrap_content"
    android:layout_alignEnd="@+id/textView2"
    android:layout_alignRight="@+id/textView2"
    android:layout_below="@+id/textView2"
    android:layout_toRightOf="@+id/ivLockImage"
    android:paddingTop="3dp"
    android:text="@string/login_screen_infi_privacy_description"
    android:textColor="@android:color/white"
    android:textSize="10sp" />

<Space
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="50dp"
    android:layout_alignStart="@+id/text1"
    android:layout_alignLeft="@+id/text1"
    android:layout_below="@+id/text1"
    android:layout_alignParentBottom="true" />
</RelativeLayout>
    <style name="TextLabel" parent="TextAppearance.AppCompat">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@android:color/white</item>
    <item name="android:textColorHighlight">@android:color/white</item>
    <item name="android:textColorLink">@android:color/white</item>
    <item name="android:textSize">20sp</item>
    <!-- Label color in TRUE state and bar color FALSE and TRUE State -->
    <item name="colorAccent">@color/accent</item>
    <item name="colorControlNormal">@android:color/white</item>
    <item name="colorControlActivated">@color/accent</item>
</style>
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.infibond.infi/com.infibond.account.login.LoginActivity}: android.view.InflateException: Binary XML file line #22: Error inflating class EditText
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2281)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
   at android.app.ActivityThread.access$800(ActivityThread.java:139)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:136)
   at android.app.ActivityThread.main(ActivityThread.java:5230)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:780)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
   at dalvik.system.NativeStart.main(NativeStart.java)
Caused by android.view.InflateException: Binary XML file line #22: Error inflating class EditText
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
       at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
       at com.infibond.account.login.LoginFragment.onCreateView(LoginFragment.java:92)
       at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
       at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
       at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
       at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
       at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
       at com.infibond.base.Inheritance.Activities.ActivityBase.onStart(ActivityBase.java:112)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
       at android.app.Activity.performStart(Activity.java:5421)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2242)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
       at android.app.ActivityThread.access$800(ActivityThread.java:139)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5230)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:780)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
       at android.content.res.TypedArray.getColor(TypedArray.java:327)
       at android.widget.TextView.<init>(TextView.java:703)
       at android.widget.EditText.<init>(EditText.java:61)
       at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:60)
       at android.support.v7.widget.AppCompatEditText.<init>(AppCompatEditText.java:56)
       at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:101)
       at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938)
       at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992)
       at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
       at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:280)
       at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:172)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
       at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
       at com.infibond.account.login.LoginFragment.onCreateView(LoginFragment.java:92)
       at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
       at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
       at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
       at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
       at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
       at com.infibond.base.Inheritance.Activities.ActivityBase.onStart(ActivityBase.java:112)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
       at android.app.Activity.performStart(Activity.java:5421)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2242)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
       at android.app.ActivityThread.access$800(ActivityThread.java:139)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5230)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:780)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:596)
       at dalvik.system.NativeStart.main(NativeStart.java)

共有1个答案

盛城
2023-03-14

解决此问题的方法是从样式配置中删除parent=“textapparance.appcompat”

所以现在样式如下所示:

<style name="TextLabel">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@color/White</item>
    <item name="android:textColorHighlight">@android:color/white</item>
    <item name="android:textColorLink">@color/White</item>
    <item name="android:textSize">20sp</item>
    <!-- Label color in TRUE state and bar color FALSE and TRUE State -->
    <item name="colorAccent">@color/accent</item>
    <item name="colorControlNormal">@android:color/white</item>
    <item name="colorControlActivated">@color/accent</item>
</style>

在xml布局中:

<android.support.design.widget.TextInputLayout
    android:id="@+id/email_wrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/loginInfiLogoRL"
    android:theme="@style/TextLabel">

    <EditText
        android:id="@+id/etUserName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/login_screen_email_hint"
        android:imeOptions="actionNext"
        android:inputType="textEmailAddress"
        android:maxLines="1"
        android:nextFocusDown="@+id/etPassword"
        android:singleLine="true"
        android:textColor="@android:color/white"
        android:textColorHighlight="@color/White"
        android:textColorHint="@android:color/white" />

</android.support.design.widget.TextInputLayout>
 类似资料:
  • 下午好,我想解决一个问题,但我不能。我有两部智能手机,一部Nexus 5(Android 6.0)和一部ZenFone 2(Android 5.0)。该错误仅在ZenFone中持续存在。 XML: Android.View.InflateException:二进制XML文件行#25:在Android.View.LayoutInflater.CreateViewFromTag(LayoutInfla

  • 嗨,我的所有应用程序都运行良好,但我在Android平板电脑中出现了故障,使用版本,但不知道为什么,因为应用程序在其他版本中运行良好。我得到的错误: 我将与一起使用android的一些代码: dimens.xml 第38行:在我的布局中定义第一个Editext的地方,有一个膨胀的问题: 在和中,我定义了提示文本的样式: 我找不到为什么会发生这样的撞车!请帮忙

  • 我用最小SDK 15和目标23构建了一个应用程序,我在中有不同的视图。Apps在android版本=>5.0上运行良好,但在android版本<5.0上崩溃,出现以下错误消息 下面是我的的代码: list_item_text.xml Build.Gradle

  • 我不知道,为什么我会有这个问题。我添加了行来构建gradle,但它仍然不起作用。出什么事了?

  • 我试图让我的布局工作,将实现支持设计库功能。然而,当我尝试运行该项目,我得到以下异常时,我的布局是加载。 二进制XML文件行#2:inflating类android.support.design.widget.错误 这是我的布局: 我尝试构建了一个简单的测试项目,该项目实现了CollapsingToolbarLayout,它没有任何问题,但一旦我尝试将其放入我的项目中,它就停止工作了。 我检查了n

  • 错误跟踪: 致命异常:主进程:com.example.user.itekit,pid:23028 android.view.inflateException:二进制XML文件行#87:在android.view.layoutinflater.createViewFromTag(layoutinflater.java:764)在android.view.layoutinflater.rinflate