Android EditText 背景文字

2023-03-25移动开发问题
28

本文介绍了Android EditText 背景文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

有没有办法设置 EditText 的背景文本?例如,我有一个带有 2 个 EditText 视图的登录屏幕,一个用于用户名,一个用于密码.我希望在 EditText 中写入文本用户名"和密码",一旦用户触摸它们,文本就会消失,但一旦用户删除了自己的条目,文本就会重新出现.

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?

推荐答案

hint 属性会为你解决这个问题.

The hint property will take care of that for you.

这篇关于Android EditText 背景文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

cocos2D iPhone中的UItextfield文本对齐问题
UItextfield text alignment issue in cocos2D iPhone(cocos2D iPhone中的UItextfield文本对齐问题)...
2024-08-12 移动开发问题
7

如何在 cocos2d 中填充纹理?
How to fill texture in cocos2d?(如何在 cocos2d 中填充纹理?)...
2024-08-12 移动开发问题
1

如何将 CCSpriteFrame 转换为 CCTexture2D (Cocos2d)
How to convert a CCSpriteFrame to a CCTexture2D (Cocos2d)(如何将 CCSpriteFrame 转换为 CCTexture2D (Cocos2d))...
2024-08-12 移动开发问题
5

如何从 CCScrollView 上的按钮更改标签文本?
How to change labels text from a button on a CCScrollView?(如何从 CCScrollView 上的按钮更改标签文本?)...
2024-08-12 移动开发问题
6

如何在 COCOS2d Android 中使用 CClistview?
How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)...
2024-08-12 移动开发问题
5