How to change the hint size of TextInputLayout

Ara Badalyan picture Ara Badalyan · Sep 29, 2015 · Viewed 45.6k times · Source

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

Answer

Santiago Mart&#237;nez picture Santiago Martínez · Jan 27, 2016

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">