InflateException when using TextInputLayout

Faced this issue when implementing AndroidX in my existing project. implementation ‘com.google.android.material:material:1.0.0-beta01’ Layout XML <com.google.android.material.textfield.TextInputLayout android:id=”@+id/userNameWrapper” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:theme=”@style/TextLabel”> Old Style <style name=”TextLabel” parent=”TextAppearance.AppCompat”> <item name=”android:textColorHint”>@color/hint_color</item> <item name=”android:textSize”>@dimen/text_20sp</item> <item name=”colorControlNormal”>@color/primaryGray</item> <item name=”colorControlActivated”>@color/colorPrimary</item> </style> New Style <style name=”TextLabel” parent=”Widget.MaterialComponents.TextInputLayout.FilledBox”> <item name=”android:textColorHint”>@color/hint_color</item> <item name=”android:textSize”>@dimen/text_20sp</item> <item name=”colorControlNormal”>@color/primaryGray</item> <item name=”colorControlActivated”>@color/colorPrimary</item> </style>

Toggle password field jetpack compose

You can use the standard TextField composable: var password by rememberSaveable { mutableStateOf(“”) } var passwordVisible by rememberSaveable { mutableStateOf(false) } TextField( value = password, onValueChange = { password = it }, label = { Text(“Password”) }, singleLine = true, placeholder = { Text(“Password”) }, visualTransformation = if (passwordVisible) VisualTransformation.None else PasswordVisualTransformation(), keyboardOptions = KeyboardOptions(keyboardType … Read more

Outlined Edit Text from Material Design

Read Outline Box . Outline text fields have a stroked border and are less emphasized. To use an outline text field, apply the following style to your TextInputLayout: style=”@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox” Dependencies implementation ‘com.android.support:design:28.0.0-alpha1’ XML <android.support.design.widget.TextInputLayout android:id=”@+id/name_text_input” style=”@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox” android:layout_width=”match_parent” android:layout_height=”wrap_content” > <android.support.design.widget.TextInputEditText android:id=”@+id/name_edit_text” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:hint=”@string/label_name” /> </android.support.design.widget.TextInputLayout> DEMO FYI Legacy support ended in Android 28 . … Read more

TextInputLayout :How to give padding or margin to hint?

The solution proposed by ganesh2shiv works for the most part, although I’ve found it also de-centres the hint text displayed inside the EditText when not focused. A better trick is to set the desired paddingTop to the EditText but also embed the extra padding within the EditText’s background. A fairly sane way to do this … Read more

TextInputLayout.setError() leaves empty space after clearing the error

Check out the docs for public void setErrorEnabled (boolean enabled) It says Whether the error functionality is enabled or not in this layout. Enabling this functionality before setting an error message via setError(CharSequence), will mean that this layout will not change size when an error is displayed. Well based on this, try setting setErrorEnabled(true) before … Read more

How to change the hint size of TextInputLayout

In your styles.xml <style name=”TextLabel” parent=”TextAppearance.Design.Hint”> <item name=”android:textSize”>16sp</item> </style> And then in your layout file: <android.support.design.widget.TextInputLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_marginLeft=”@dimen/activity_horizontal_margin” android:layout_marginRight=”@dimen/activity_horizontal_margin” android:layout_marginTop=”12dp” app:hintTextAppearance=”@style/TextLabel” android:minHeight=”30dp”>

Couldn’t resolve resource @id/visible when using TextInputLayout

This nags one with the Rendering Problems window How to fix: add these values to any values file (the filename doesn’t appear to matter, I use ids.xml, you can use an existing one as well, such as colors.xml or strings.xml) <?xml version=”1.0″ encoding=”utf-8″?> <resources> <item name=”visible” type=”id”/> <item name=”masked” type=”id”/> </resources>

How to add floating label on Spinner

I want the text size, font and colour to match that of the TextInputLayout‘s floating label. This can be achieved easily without any external libraries. After trying to hack the TextInputLayout and even making my own custom view, I realized that using a simple TextView takes much less code and it’s probably more efficient. The … Read more

How to set TextInputLayout error message colour?

Create a custom style which uses @android:style/TextAppearance as parent in your styles.xml file: <style name=”error_appearance” parent=”@android:style/TextAppearance”> <item name=”android:textColor”>@color/red_500</item> <item name=”android:textSize”>12sp</item> </style> And use it in your TextInputLayout widget: <android.support.design.widget.TextInputLayout android:id=”@+id/emailInputLayout” android:layout_width=”match_parent” android:layout_height=”wrap_content” app:errorTextAppearance=”@style/error_appearance”> Edit: Set the hint on the object, which is inside your TextInputLayout (EditText, TextView, etc.) to hold different colors for the hint … Read more