Android TextInputField Inflator Error

后端 未结 13 1312
野的像风
野的像风 2020-12-03 06:55

Had a crash while trying to use the new TextInputField for Android and wanted to share my solution.

Trying the new TextInputField in the android appcomp

相关标签:
13条回答
  • 2020-12-03 07:19

    you might have added it compile 'com.android.support:appcompat-v7:22.2.0' but you need to add compile 'com.android.support:design:22.2.0'

    you can try this dependencies:

    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:design:22.2.0'
    

    in your gradle file.

    0 讨论(0)
  • 2020-12-03 07:21

    Finally I got this working...as per as the latest changes in the library itself, change the library from

    <android.support.design.widget.TextInputLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/txt_input"
            android:layout_margin="@dimen/activity_horizontal_margin"
            app:layout_constraintTop_toBottomOf="@+id/edt_first_name"
            app:layout_constraintStart_toEndOf="@+id/guideline"
            app:hintEnabled="false">
    
            <android.support.design.widget.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Floating Hint Disabled" />
    
        </android.support.design.widget.TextInputLayout> 
    

    to

    <com.google.android.material.textfield.TextInputLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/txt_input"
            android:layout_marginTop="@dimen/activity_horizontal_margin"
            app:layout_constraintTop_toBottomOf="@+id/edt_first_name"
            app:layout_constraintStart_toEndOf="@+id/guideline"
            app:hintEnabled="false">
    
            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Floating Hint Disabled" />
    
        </com.google.android.material.textfield.TextInputLayout>
    
    0 讨论(0)
  • 2020-12-03 07:22

    This happened to me as well, and I came up with a solution that does not require changing the App Theme, but merely changing the Theme of the TextInputLayout:

    <android.support.design.widget.TextInputLayout
        android:id="@+id/testingInputLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/Theme.AppCompat">
    
       <EditText
           android:id="@+id/testingEditText"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:hint="@string/testText"
           android:inputType="textEmailAddress" />
    
    </android.support.design.widget.TextInputLayout>
    

    You will need to add the appCompat library if you have not already:

    compile 'com.android.support:appcompat-v7:23.0.1'
    
    0 讨论(0)
  • 2020-12-03 07:25

    in adroidx it worked for me i have the libraries

     implementation 'com.android.support:appcompat-v7:28.0.0'
        //design widget
        implementation 'com.android.support:design:28.0.0'
    

    i change

    <android.support.design.widget.TextInputLayout
    

    for

    <com.google.android.material.textfield.TextInputLayout
    
    0 讨论(0)
  • 2020-12-03 07:26

    Make sure the LayoutInflater is created from an AppCompatActivity

    ex.

    instead of

    inflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    

    use:

    inflater = LayoutInflater.from(<appCompatActivity>);
    
    0 讨论(0)
  • 2020-12-03 07:28

    I had the same issue with Android Studio 3.0.1

    All you need to add the following line into gradle.properties (Project Propeties):

    android.enableAapt2=false

    0 讨论(0)
提交回复
热议问题