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 演示中的代码,但仍然没有成功。

4

2 回答 2

2

android:background在我的布局中使用

<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">

它肯定是看穿的,我可以看到它下面的其他活动。

于 2011-07-26T11:25:25.523 回答
0

我会去找 AndroidManifest.xml,寻找目标活动,然后设置:android:theme="@android:style/Theme.Translucent"

于 2013-04-23T07:29:20.707 回答