简体   繁体   English

Android EditText透明背景

[英]Android EditText Transparent Background

I want to have a transparent background for Android EditText widget. 我希望Android EditText小部件具有透明背景。 How is that possible? 怎么可能?

试试这个

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

您也可以使用java代码进行设置

myTextView.setBackgroundColor(Color.TRANSPARENT);

非常简单:

android:alpha="0.5"
  1. in xml file you use this property: 在xml文件中,您使用此属性:

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

  2. and in java file run time in onCreate method use: 并且在onCreate方法的java文件运行时使用:

    edittext.setBackgroundColor(Color.TRANSPARENT);

将此属性放在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. 与任何其他视图/组件一样,EditText可以在xml文件中自定义。 You just need to include below attribute in the EditText attributes. 您只需要在EditText属性中包含以下属性。

 android:background="@null"

set this in layout will work 在布局中设置它将起作用

android:background="@color/transparent

and add this in colors.xml 并在colors.xml中添加它

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

使用半透明主题

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

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

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