1. Are you ready for the Galaxy S20? Here is everything we know so far!

Adding a TextInputLayout

Discussion in 'Android Development' started by Greum, Jul 25, 2019.

  1. Greum

    Greum Well-Known Member
    Thread Starter

    I'm trying to add a floating label to one of my EditTexts .

    I have added the dependency

    implementation 'com.android.support:design:28.0.0'

    And then I wrapped the EditText with a TextInputLayout and changed the EditText to TextInputEditText

    Code (Text):
    1.     <android.support.design.widget.TextInputLayout
    2.         android:layout_width="match_parent"
    3.         android:layout_height="wrap_content">
    4.  
    5.         <android.support.design.widget.TextInputEditText
    6.             android:id="@+id/editName"
    7.             android:layout_width="match_parent"
    8.             android:layout_height="wrap_content"
    9.             android:hint="@string/text_name"
    10.             android:inputType="textPersonName" />
    11.  
    12.     </android.support.design.widget.TextInputLayout>
    13.  
    But when I run that layout the app crashes.

    The first few lines of the error log are:

    Code (Text):
    1. 2019-07-25 19:40:45.717 7492-7492/com.domain.agedatabase E/AndroidRuntime: FATAL EXCEPTION: main
    2.     Process: com.domain.agedatabase, PID: 7492
    3.     android.view.InflateException: Binary XML file line #6: Binary XML file line #6: Error inflating class android.support.design.widget.TextInputLayout
    4.     Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class android.support.design.widget.TextInputLayout
    5.     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.TextInputLayout" on path: DexPathList[[zip file "/data/app/com.domain.agedatabase-XIahRtMJot7YD30IBJ79pQ==/base.apk", zip file "/data/app/com.domain.agedatabase-XIahRtMJot7YD30IBJ79pQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.domain.agedatabase-XIahRtMJot7YD30IBJ79pQ==/split_lib_resources_apk.apk", zip file
    6.  
     

    Advertisement

  2. Deleted User

    Deleted User Guest

    Do you have this dependency in your build.gradle?

    compile 'com.android.support:design:25.3.1'
     
  3. Greum

    Greum Well-Known Member
    Thread Starter

    Yes, I added that but I get an error saying to use version 28 (compileSdkVersion), so I changed it to 28.0.0. Then I get a warning saying compile is obsolete and should be replaced with implementation, so I ended up with

    implementation 'com.android.support:design:28.0.0'
     
  4. Greum

    Greum Well-Known Member
    Thread Starter

    I'm thinking maybe I should be using the androidx equivalent, but finding out what that should be is another matter...
     
  5. Greum

    Greum Well-Known Member
    Thread Starter

    Okay, so I created a simple app in android then refactored it to androidx.

    The tags seem to be changed

    <com.google.android.material.textfield.TextInputLayout

    and

    <com.google.android.material.textfield.TextInputEditText

    and it doesn't need the extra dependency, so long as there's

    implementation 'com.google.android.material:material:1.0.0'
     
  6. wseng92

    wseng92 Android Enthusiast

    Has your problem been solved?
     
  7. Greum

    Greum Well-Known Member
    Thread Starter

    Yes. I didn't want to mark my reply as the best answer, but that is the answer :p
     
  8. wseng92

    wseng92 Android Enthusiast

    I have marked it. Thanks for posting your solution here.
     
    Greum likes this.
  9. havens1515

    havens1515 Lurker

    OMG thank you for this! I've been having the same issue, and couldn't find the answer anywhere! So glad I found this!
     
  10. Thanks lots Greum. You saved me on the issue of com.google.android.material.textfield.TextInputLayout
     
    Greum likes this.
Loading...

Share This Page

Loading...