[英]EditText background color
I have an Activity that consists only of a huge EditText, full screen. 我有一个仅包含一个巨大的全屏EditText的Activity。
To match with my app's colours, i changed the background color of the EditText. 为了与我的应用程序的颜色匹配,我更改了EditText的背景颜色。 But although it occupies the whole screen, it only changes the first line.
但是,尽管它占据了整个屏幕,但它仅更改了第一行。 Everytime i press enter i go to a new line and that line gets the background i want.
每次按Enter键,我都会转到新行,并且该行会获取我想要的背景。
What propertie can i set in order to do this? 我可以设置什么属性才能执行此操作? I just can't see it!
我只是看不到!
我将用视图包装EditText并在视图上设置背景色。
为了更改已经带有背景的视图的背景,最好提供自己的图像,然后使用patch9进行适当的调整大小,希望对您有所帮助。
@everyone: @大家:
While searching for a solution for this same kind of problem i found this page. 在寻找解决此类问题的方法时,我找到了此页面。 While reading the solutions i thought to myself: "There must be a better way to do this, instead of making your own styles and widgetborders, etcetera, etcetera, ....
在阅读解决方案时,我对自己心想:“必须有一种更好的方法来做到这一点,而不是制作自己的样式和部件,等等。”
Therefore, i present to you: the 1 LINE OF CODE SOLUTION!!! 因此,我向您介绍:1行代码解决方案!!! No trolling.
没有巨魔。
<your-widget-component-that-has-a-background-color>.getBackground().setColorFilter(Color.<your-desired-color>, PorterDuff.Mode.MULTIPLY);).
It works like this: 它是这样的:
I haven't profoundly read the PorterDuff class documentation, but honestly, ain't it a powerful bit of code? 我没有深入阅读PorterDuff类文档,但是老实说,它不是功能强大的代码吗?
With kind regards, 亲切的问候,
如何设置EditText
小部件的背景颜色:
editText.setBackgroundColor(Color.RED);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.