Reputation: 638
I would like to change floating label text size in Android material EditText
, when I set as follows:
<android.support.v7.widget.AppCompatEditText
android:id="@+id/edt_current"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/str_current"
android:inputType="number"
android:singleLine="true"
android:textSize="20sp" />
It just changes the text size for hint and input Text.
Since, Floating Label Text Size seems too small in my UI, I would like to change it, any solution?
Upvotes: 9
Views: 14084
Reputation: 638
The accepted answer helped me a lot to find my solution (i.e. setting the exact font size, not only using small, medium, ...).
In addition, by defining a style for app:hintTextAppearance, you can also simply set the color of floating label :)
in styles.xml:
<style name="CustomTextAppearance" parent="@android:style/TextAppearance">
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/colorAccent</item>
</style>
and in your TextInputLayout:
<android.support.design.widget.TextInputLayout
android:id="@+id/lyt_goal"
style="@style/CustomTextInput"
app:hintTextAppearance="@style/CustomTextAppearance">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/edt_goal"
android:hint="@string/str_goal" />
Upvotes: 13
Reputation: 348
Try following code. This may help you:
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/TextAppearance.AppCompat.Medium.Inverse">
You may use app:hintTextAppearance="@style/TextAppearance.AppCompat.Small.Inverse"
instead.
Upvotes: 18
Reputation: 510
Try The Below Code It Works In Normal State
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:theme="@style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Hiiiii"
android:id="@+id/edit_id"/>
</android.support.design.widget.TextInputLayout>
In Styles Folder TextLabel Code
<style name="TextLabel" parent="TextAppearance.AppCompat">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">@color/Color Name</item>
<item name="android:textSize">20sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">@color/Color Name</item>
<item name="colorControlNormal">@color/Color Name</item>
<item name="colorControlActivated">@color/Color Name</item>
</style>
Set To Main Theme of App,It Works Only Highlight State Only
<item name="colorAccent">@color/Color Name</item>
Hope this will help you !
Upvotes: 2