无法使我的活动窗口半透明
我试图使我的 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 演示中的代码,但仍然没有成功。
I'm trying to make my Activity
translucent, i.e. see-through, but it's not working. It's always opaque. That's my code so far:
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));
}
}
I've been looking at the code from the official API demos but still no success.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在布局中使用 android:background
,它肯定是透明的,我可以看到它下面的其他活动。
I use
android:background
in my layoutand its certainly see through, I can see the other activity below it.
我会寻找 AndroidManifest.xml,查找目标活动,然后设置:
android:theme="@android:style/Theme.Translucent"
I would go for the AndroidManifest.xml, look for the target activity, and set:
android:theme="@android:style/Theme.Translucent"