Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the hint size of TextInputLayout

This is my xml

<android.support.design.widget.TextInputLayout                 style="@style/main_input_text"                 android:layout_marginTop="@dimen/activity_medium_margin"                 app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout">                  <android.support.v7.widget.AppCompatEditText                     style="@style/main_edit_text"                     android:inputType="text" />  </android.support.design.widget.TextInputLayout> 

And this is style

<style name="main_input_text">         <item name="android:layout_width">match_parent</item>         <item name="android:layout_height">@dimen/activity_edittext_height</item>         <item name="android:background">@drawable/mc_shape_border_button_transparent</item>         <item name="android:gravity">center_vertical</item>         <item name="android:paddingTop">@dimen/activity_extra_small_margin</item>         <item name="android:paddingBottom">@dimen/activity_extra_small_margin</item>         <item name="android:keyTextSize">8sp</item>         <item name="android:textSize">8sp</item> </style> 

I don't find something like hintSize, textSize and keyTextSize not helping

like image 756
Ara Badalyan Avatar asked Sep 29 '15 11:09

Ara Badalyan


People also ask

How do I change TextInputLayout text size in Android?

You only need to change the android:textSize attribute for the TextInputEditText for the hint size to change.

How do I increase hint size on android?

Using onFocusChanged() listener for changing hint font size is also an option, as addTextChangeListener() won't trigger when user clicks on text field, and blinking cursor will resize to hint font. Also, unlike with TextChangeListener, there is no need to set initial hint font size separately.

How do I remove the default padding in TextInputLayout?

You can just set the start and end padding on the inner EditText to 0dp. Here's a screenshot with Show Layout Bounds turned on so you can see that the hints go all the way to the edge of the view.


2 Answers

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"> 
like image 56
Santiago Martínez Avatar answered Sep 21 '22 22:09

Santiago Martínez


Change the TextInputLayout's app:errorTextAppearance in XML.

<android.support.design.widget.TextInputLayout             android:layout_width="wrap_content"             android:layout_height="wrap_content"             app:errorTextAppearance="@style/CustomTextInputLayoutStyle.ErrorTextStyle"> 

Where CustomTextInputLayoutStyle.ErrorTextStyle is defined in styles.xml as

<style name="CustomTextInputLayoutStyle.ErrorTextStyle" parent="TextAppearance.Design.Error">         <item name="android:textSize">10sp</item> </style> 
like image 32
nt-complete Avatar answered Sep 22 '22 22:09

nt-complete