Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error inflating TextInputLayout.Outlined after switching to AndroidX

Error inflating class android.support.design.widget.TextInputLayout after switching to AndroidX and enabling style/Widget.MaterialComponents.TextInputLayout.OutlinedBox

Hello friends, today I switched my projects to Androidx (required for a new lib I need), and I get errors about my TextInputLayout.

Please note that it compiles perfectly when I remove OulinedBox style, but I absolutely need it for this project.

Does anyone knows a way to make OulinedBox TextInputLayout style work with AndroidX ?

Thank you so much for your help and time.

<android.support.design.widget.TextInputLayout
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginHorizontal="60dp"
    android:layout_marginTop="20dp"
    app:boxStrokeColor="@color/gradient_begin_purple">

    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/login"
        android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
like image 331
LNTK Avatar asked Mar 04 '23 17:03

LNTK


2 Answers

I have encountered this problem. I tried all things that given from stackoverflow but unfortunately couldn't find any solution. At the end I found the points that i missed. (I assume that you put material design dependency in your build.gradle)

1)Your app them must be like followings(in values and values-21 folders)

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">

2)set activity theme to AppTheme in your manifest.xml

<activity
            android:name=".ui.activities.SplashActivity"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme"
like image 76
Ali Gürelli Avatar answered Mar 10 '23 01:03

Ali Gürelli


Add implementation "com.google.android.material:material:1.1.0-alpha02" in place of support design library. It is working perfectly for me after replacing above.

like image 29
Anubhav Gupta Avatar answered Mar 09 '23 23:03

Anubhav Gupta