2011-07-26 25 views
2

我試圖讓我的Activity半透明,即透視,但它不工作。它總是不透明的。這是到目前爲止我的代碼:無法使我的活動窗口半透明

public class SvetlinTranslucentActivity extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     Window w = getWindow(); 
     w.setFormat(PixelFormat.RGBA_8888); 
     w.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); 
     w.setBackgroundDrawable(new ColorDrawable(0x00FF0000)); 
    } 
} 

我一直在尋找來自官方的API演示,但仍然沒有成功的代碼。

+0

你看着http://developer.android.com/reference/android/view/Window.html? setBackgroundDrawable方法說明如何使它透明 – manelizzard

+0

嗯。這就是我正在做的,不是嗎?! –

+0

嘗試使用ColorDrawable(0)或ColorDrawable(null) – manelizzard

回答

2

我在佈局

<RelativeLayout android:id="@+id/RelativeLayout01" 
android:layout_width="fill_parent" android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:background="#D0000000"> 

和肯定看到過,我可以看到它下面的其他活動使用android:background

+0

它不適合我。 –

0

我會去的AndroidManifest.xml中,認準了目標活動,並設置:android:theme="@android:style/Theme.Translucent"