开发者

Android EditText Transparent Background

I want to have a transparent background for Android EditText widget. H开发者_StackOverflow社区ow is that possible?


Try this

android:background="@null"


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


You can also set it using java code

myTextView.setBackgroundColor(Color.TRANSPARENT);


  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);


Very simple:

android:alpha="0.5"


Put this property in edittext:

android:background="@null"


android:background="#00000000"


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);


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"


set this in layout will work

android:background="@color/transparent

and add this in colors.xml

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


For XML code use:

android:background="@color/transparent

or

android:background="@null"

For Java code:

myEditText.setBackgroundColor(Color.TRANSPARENT);


Use translucent theme

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜