Android EditText background text

爷,独闯天下 提交于 2019-11-29 11:49:35

问题


Is there a way to set the background text of an EditText? for instance, I have a login screen with 2 EditText views, one for username and one for password. I want the text "Username" and "Password" be written inside the EditText, and once the user touches those the text disappears but once user deleted his own entry, text re-appears.

Is there a property for that or should I implement this on my own with events and stuff?


回答1:


The hint property will take care of that for you.




回答2:


Use hint property, or setHint method.



来源:https://stackoverflow.com/questions/4489646/android-edittext-background-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!