Android EditText Transparent Background

2019-01-17 09:26发布

问题:

I want to have a transparent background for Android EditText widget. How is that possible?

回答1:

Try this

android:background="@null"


回答2:

android:background="@android:color/transparent"


回答3:

You can also set it using java code

myTextView.setBackgroundColor(Color.TRANSPARENT);


回答4:

Very simple:

android:alpha="0.5"


回答5:

Put this property in edittext:

android:background="@null"


回答6:

android:background="#00000000"


回答7:

You can also do it programitically like this:

 TypedValue value= new TypedValue();
 getApplicationContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, value, true);

  myButton.setBackgroundResource(value.resourceId);


回答8:

EditText, like any other view/component can be customized in the xml file. You just need to include below attribute in the EditText attributes.

 android:background="@null"


回答9:

  1. in xml file you use this property:

    android:background="@android:color/transparent"

  2. and in java file run time in onCreate method use:

    edittext.setBackgroundColor(Color.TRANSPARENT);



回答10:

set this in layout will work

android:background="@color/transparent

and add this in colors.xml

<color name="transparent">#00000000</color>


回答11:

Use translucent theme

<activity android:theme="@android:style/Theme.Translucent">