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 appcompat library was crashing my app. Here was my layout xml.
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="e-mail"
android:inputType="textEmailAddress"
android:singleLine="true"/>
</android.support.design.widget.TextInputLayout>
The error I got:
android.view.InflateException: Binary XML file line #20: Error inflating class android.support.design.widget.TextInputLayout.
SOLUTION:
Add the hintTextAppearance
attribute to your TextInputLayout
, so the lead tag looks like this:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@android:style/TextAppearance.Medium">
Make sure the LayoutInflater is created from an AppCompatActivity
ex.
instead of
use:
you might have added it
compile 'com.android.support:appcompat-v7:22.2.0'
but you need to addcompile 'com.android.support:design:22.2.0'
you can try this dependencies:
in your gradle file.
Use the following:
I had the same issue with Android Studio 3.0.1
All you need to add the following line into gradle.properties (Project Propeties):
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:
You will need to add the appCompat library if you have not already:
I got the same issue when inflating XML containing
TextInputLayout
. The problem was fixed by setting the correct Style on my application. Just like it says here : android design support libraryI've the following issue
My style.xml was
As it said in this post on Design Support Library
So NO NEED TO ADD the following line inside the gradle file
I found the link behove explaining that the Design Support Library is part of the AppCompat and it require the AppCompat Theme base to work. So I've modify my style.xml to be
And it worked.