简体   繁体   English

如何在不透明的EditText背景后面放置一个不透明的白色矩形?

[英]How can I place an opaque white rectangle behind my translucent EditText background?

I'm working with Android and I want to be able to have the equivalent of two backgrounds for one EditText, essentially. 我正在使用Android,并且希望一个EditText基本上具有两个背景。 The text will change the color of the ET background as it types, but because it has to be slightly opaque so it's not a solid color, it may show the total View background color too, which will be changing from white as well. 文本将随着输入的类型改变ET背景的颜色,但是由于它必须稍微不透明,因此它不是纯色,因此它也可能会显示View的总背景颜色,而背景颜色也会从白色变化。 To solve this I would like to have a constant white background behind the color-changing translucent background behind the EditText. 为了解决这个问题,我想在EditText后面的变色半透明背景后面有一个恒定的白色背景。 If any more practical, possible approach is apparent, please share! 如果有任何更实际,可行的方法,请分享!

put the edit text inside a another layout and set the background colour. 将编辑文本放在另一个布局中并设置背景颜色。

So if your xml was something like this 因此,如果您的xml是这样的

.
.
.
<EditText 
android:layout_width="500dp"
android:layout_height="40dp" />
.
.
.

Now it will become like 现在它将变得像

.
.
.
<RelativeLayout

    android:layout_width="500dp"
    android:layout_height="40dp"
    android:background="@color/White" >

    <EditText
          android:layout_width="match_parent"
          android:layout_height="match_parent" />
</RelativeLayout>
.
.
.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM