YesPapa
YesPapa

Reputation: 117

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?

Upvotes: 3

Views: 4721

Answers (2)

Olena Y
Olena Y

Reputation: 233

you can set it via styles

create HintTextAppearance style with

<item name="android:textSize">Your text size</item>

and set app:hintTextAppearance="@style/Your style" to your InputTextLayout

Upvotes: 1

KeLiuyue
KeLiuyue

Reputation: 8237

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);

Upvotes: 2

Related Questions