我想要一个半透明的LinearLayout(不是透明的)。
我想在我的Activity中模拟一个对话框。所以我尝试了以下代码:
在Manifest文件中:
在 Activity 的 onCreate 方法中:
但它没有起作用,因为我根本看不到主屏幕桌面。有什么想法吗?
我也尝试过在xml中这样做,但是它也没有起作用:
在Manifest文件中:
android:theme="@android:style/Theme.Translucent"
在 Activity 的 onCreate 方法中:
LinearLayout MyLayout = (LinearLayout)findViewById(R.id.MyLayout);
MyLayout.setBackgroundColor(Color.BLACK);
MyLayout.getBackground().setAlpha(50);
但它没有起作用,因为我根本看不到主屏幕桌面。有什么想法吗?
我也尝试过在xml中这样做,但是它也没有起作用:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MyLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#22FFFFFF"
android:orientation="vertical" >
</LinearLayout>