Search code examples
androidandroid-layoutandroid-edittextandroid-textinputlayout

TextInputLayout's floating hint text size


In my layout I am using EditText inside TextInputLayoutso I can have floating hint. Right now I would like to create some TextViews which sizes are equal to that of floating hint. But how can I know the right size value? Is it somehow determinant of a EditText's android:textSizeattribute?


Solution

  • You can do like this.

    change EditText's text size

    android:textSize="12sp"
    

    You can do this in the .java.

    editText.setTextSize(12);
    

    change TextInputLayout's LEFT-TOP text size

    app:hintTextAppearance="@style/text_in_layout_hint_Style"
    

    style code

    <style name="text_in_layout_hint_Style">
        <item name="android:textColor">#FF0000</item>
        <item name="android:textSize">20sp</item>
    </style>
    

    You can do this in .java.

    textInputLayout.setHintTextAppearance(R.style.text_in_layout_hint_Style);