2011-04-19 133 views

回答

128

試試這個

android:background="@null" 
+0

我想這樣做的佈局文件添加此。有可能的? – 2013-02-27 10:43:11

+0

@DhawalSodhaParmar是的。這是在佈局 – Nabin 2015-03-27 03:51:40

+0

完成謝謝,這工作。 – 2015-08-25 10:32:48

-6

使用半透明的主題

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

在這裏查看更多http://developer.android.com/guide/topics/ui/themes.html – yogsma 2011-04-19 06:25:57

38
android:background="@android:color/transparent" 
+0

我想在佈局文件中做到這一點。有可能的? – 2013-02-27 10:44:55

9

您還可以設置它使用Java代碼

myTextView.setBackgroundColor(Color.TRANSPARENT); 
8

很簡單:

android:alpha="0.5" 
+1

用alpha來玩這不是個好主意 - 這是非常(!!!)糟糕的渲染性能的一個非常常見的來源。 – dominus 2015-06-22 12:06:25

2

將這個屬性中的EditText:

android:background="@null" 
2
android:background="#00000000" 
1

你也可以做到這一點programitically這樣的:

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

    myButton.setBackgroundResource(value.resourceId); 
1

的EditText,像任何其他視圖/組件可以在自定義xml文件。 您只需要在EditText屬性中包含以下屬性。

android:background="@null" 
1
    xml文件中
  1. 使用此屬性 機器人:背景= 「@安卓:彩色/透明」
  2. ,並在onCreate方法使用 edittext.setBackgroundColor的java文件運行時(Color.TRANSPARENT );
0

這集佈局將工作

android:background="@color/transparent 

和colors.xml

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