Is it possible to change the font for the hint displayed in the EditText
field? I want to set the font in the xml itself.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I haven't find out any useful way to change hint font in XML.But you can achieve like this:
This is a wrong answer to the question. I tried deleting but i cannot except the moderators. Kindly ignore the answer or feel free to update the answer. This answer is misleading. Sorry :).
You can change the font of
EditText
just likeTextView
. But you cannot change the typeface ofhint
.@francisco_ssb's answer is correct. However, I will provide an alternative solution which helps to change not only a hint's font, but also its size and style. I hope this solution will be helpful.
1) Create a custom
Hint
object:2) Create custom
MetricAffectingSpan
object:3) Use:
I can change the hint font by use this library .
After compiling the library you must create a class of applications and the class definition following command:
After each activity you want Override it with the following command:
Its not possible in XML -
Text and hint can only have the same font in XML.
You can change it with a SpannableString and a Custom TypefaceSpan.
First, create a Custom TypefaceSpan class:
Then just set the TypefaceSpan to a SpannableString:
And finally just set the hint of your EditText: