I am using TextInputEditText
in my registration screen. I am able to set the style of floating label. I want to set the custom font on hint and text of TextInputEditText
using style. Does anyone know whats way of it ?
<android.support.design.widget.TextInputLayout
android:id="@+id/til_registration_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:paddingEnd="@dimen/default_view_padding_right_8dp"
android:paddingStart="@dimen/default_view_padding_left_8dp"
android:textColorHint="@color/colorSecondaryText"
app:hintTextAppearance="@style/AppTheme.InputLayoutStyle"
app:layout_constraintTop_toBottomOf="@id/textview_registration_title">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/registration_name"
android:imeOptions="actionNext"
android:singleLine="true"
android:textColor="@color/colorPrimaryText" />
</android.support.design.widget.TextInputLayout>
styles.xml
<style name="AppTheme.InputLayoutStyle" parent="TextAppearance.AppCompat">
<item name="android:textColor">@color/colorPrimary</item>
<item name="fontFamily">@font/lato_light</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:textViewStyle">@style/AppTheme.TextView</item>
<item name="buttonStyle">@style/AppTheme.Button</item>
</style>
I want to set style for entire application.
Method 1 - Create TextInputLayout programmatically with wrapping Context with android. view. ContextThemeWrapper and use. TextInputLayout layout = new TextInputLayout(new ContextThemeWrapper(getContext(), R.
You can use the attribute style="@style/your_style" that is defined for any widget. The attribute parent="@android:style/Widget. EditText" is important because it will ensure that the style being defined extends the basic Android EditText style, thus only properties different from the default style need to be defined.
Old question but worth to answer.
Just set the "textInputStyle" to style the TextInputLayouts and "editTextStyle" to style the TextInputEditTexts in your app theme.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:textViewStyle">@style/AppTheme.TextView</item>
<item name="buttonStyle">@style/AppTheme.Button</item>
<item name="textInputStyle">
@style/MyCustomTextInputStyle
</item>
<item name="editTextStyle">
@style/MyCustomEditTextStyle
</item>
</style>
<style name="MyCustomTextInputStyle" parent="Widget.Design.TextInputLayout">
<item name="android:textColorHint">@color/colorSecondaryText</item>
<item name="hintTextAppearance">@style/any_style_you_may_want"</item>
</style>
<style name="MyCustomEditTextStyle" parent="Widget.AppCompat.EditText">
<item name="android:textColor">@color/colorPrimary</item>
<item name="fontFamily">@font/lato_light</item>
</style>
This will apply the same style to all TextInputLayout and TextInputEditText in you application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With