Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change hint text size in TextInputLayout

Suppose I want to change text size. I'm doing it in code and it looks like this:

_textInputLayout.EditText.SetTextSize(Android.Util.ComplexUnitType.Dip, 40);

When I write text in the entry it looks like 40dip text. But when entry is empty hint text looks like 16-18dip.

Is there any way to change hint text size?

like image 746
Pleshkov Ivan Avatar asked Mar 14 '23 09:03

Pleshkov Ivan


1 Answers

Changing the final hint size / floating label size is possible via a style and calling SetHintTextAppearance using something like the following:-

_nativeView.SetHintTextAppearance(App6.Droid.Resource.Style.MyTextInputLayout);

Where MyTextInputLayout is something along the lines of:-

<style name="MyTextInputLayout" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/blue</item>
    <item name="android:textSize">44sp</item>
</style>

However the textSize from this style is only applied to the final destination, when you start to enter some text in.

From what I can see, and including the properties on the object, it doesn't appear to be possible to change the starting font size of the hint unfortunately at the moment?

Where as EditText is exposed, and you can alter things there. The Hint portion is not handled at all by it, and instead by the TextInputLayout. There appears no object exposed to get access to customize this specifically for the Hint.

like image 65
Pete Avatar answered Mar 25 '23 21:03

Pete