سؤال

I'm working with Android and I want to be able to have the equivalent of two backgrounds for one EditText, essentially. 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. To solve this I would like to have a constant white background behind the color-changing translucent background behind the 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

.
.
.
<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 مع الإسناد
لا تنتمي إلى StackOverflow
scroll top