Shreyash Khole
Shreyash Khole

Reputation: 580

Textinputlayout inflate exception in KitKat

Here is my following code :

  <android.support.design.widget.TextInputLayout 
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_marginTop="@dimen/margin_5dp"
                    android:layout_weight="1"
                    android:gravity="left"

                    android:textColor="@color/text_input_layout"
                    android:textColorHint="@color/text_input_layout"
                    android:theme="@style/Theme.AppCompat"
        app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout">

                    <EditText
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/button_height"
                        android:layout_gravity="bottom"
                        android:layout_marginTop="@dimen/margin_5dp"
                        android:background="@drawable/textview_background"

                        android:imeOptions="flagNoExtractUi"
                        android:inputType="textNoSuggestions"
                        android:maxLength="50"
                        android:paddingLeft="3dp"
                        android:textColor="#FFFFFF"
                        android:textColorHint="@color/black"
                       android:textCursorDrawable="@drawable/color_cursor"
                        android:textSize="@dimen/text_size">

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

The style that has been defined to the activity.

<style name="MyTheme" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/AppActionBar</item>
    <item name="android:textSize">@dimen/text_size</item>
    <item name="android:textColor">@color/black</item>
</style>

Manifest Code :

<activity
        android:name=".MyActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:label="@string/MyActivity"
        android:screenOrientation="landscape"
        android:windowSoftInputMode="adjustPan|adjustResize"
        android:theme="@style/MyTheme" />

I have tried a lot of examples from stackoverflow but did not work on Android Os KITKAT(API 17). Apps minimum target is 17. I get the following runtime error only on Kitkat.

android.view.InflateException: Binary XML file line #138: Error inflating class android.support.design.widget.TextInputLayout

If anyone could help thanks in advance.

Upvotes: 0

Views: 703

Answers (1)

Mina Fawzy
Mina Fawzy

Reputation: 21452

If you don't want to face in trouble with old version, make sure you don't use any vector image and reference it by old way android:src, use app:srcCompat instead .

Use appcompat view instead old views.

Use android.support.v7.widget.AppCompatEditText instead of EditText.

Update your support library to latest version.

UPDATE

Make sure your ActivityName extend AppCompatActivity not Activity or FragmentActivity (by the way when using AppCompatActivity in the run time converted to AppCompat Views).

Upvotes: 3

Related Questions