Android EditText Transparent Background

2019-01-17 09:22发布

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

11条回答
SAY GOODBYE
2楼-- · 2019-01-17 09:38

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"
查看更多
够拽才男人
3楼-- · 2019-01-17 09:41
  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);

查看更多
Bombasti
4楼-- · 2019-01-17 09:42

Use translucent theme

<activity android:theme="@android:style/Theme.Translucent">
查看更多
Bombasti
5楼-- · 2019-01-17 09:44

Put this property in edittext:

android:background="@null"
查看更多
爱情/是我丢掉的垃圾
6楼-- · 2019-01-17 09:45
android:background="#00000000"
查看更多
Animai°情兽
7楼-- · 2019-01-17 09:46

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);
查看更多
登录 后发表回答