Search code examples
javaandroidandroid-layoutuser-input

Failed to find style 'textInputStyle' in current theme


I am very new to android develop & Android Studio. I was trying to create a simple app with a text input field so that that user can input text. (Again very new to this and just messing around with android development/studio).

Anyway, when I've added the 'TextInputLayout' and then a input text field from the palette, I get the above error.

I have tried to refresh as hinted to me. Also tried uninstalling Android Studio, different APKs. I have tried some solutions from another post on stack-overflow by looking through the manifest file and the style.xml files and haven't had any luck.

Was wondering if anyone could help me resolve this issue again I am extremely new to android development and Programming in general, so it may be an easy fix but I've ran out of ideas LOL.

Below is the code I currently have my 'activity_main.xml' file.

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="10"
        android:hint="@string/input_text"
        android:inputType="text" />

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


Solution

  • This is an android studio bug with dependencies of support library. I also faced same problem few days ago.

    • Go to build.gradle file (inside app folder).

    • Then change the version of dependencies of support library -- replace 28.0.1-alpha3 to 28.0.1-alpha1

    • Then go to styles.xml file (at app/res/values folder) and add this item in your style named AppTheme.
      <item name="textInputStyle">@style/Widget.Design.TextInputLayout</item>