可以在EditText字段中设置背景文本吗?
TextField field = new TextField("(*.xml, *.java...)");
field.setStyle("-fx-prompt-text-fill: transparent;");
在java中? 我不知道这个词,但我想将文本作为模板或在 editText 的背景中使用,例如登录表单等,有什么想法吗?
就像本网站上的搜索字段一样。
最佳答案
你的问题不是很清楚,但我认为你只是要求提示文字?
TextField field = new TextField();
field.setPromptText("(*.xml, *.java...)");
来自documentation :
TextField supports the notion of showing prompt text to the user when there is no text already in the TextField (either via the user, or set programmatically). This is a useful way of informing the user as to what is expected in the text field, without having to resort to tooltips or on-screen labels.
关于java - 是否可以在java代码中为文本字段设置背景文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33614364/