gpt4 book ai didi

android - 为什么以编程方式设置主题会产生与通过 list 不同的结果?

转载 作者:行者123 更新时间:2023-11-30 03:01:06 26 4
gpt4 key购买 nike

我很好奇我是不是做错了什么,或者这只是一个错误...

当我像这样在 list 中为我的 Activity 设置主题时:

<activity
android:theme="@android:style/Theme.Dialog"
...>

生成的 Activity 有一个半不透明的背景,通过它我可以看到堆栈中的下一个 Activity。

但是,当我将该命令从我的 list 中删除并在我调用 super.onCreate 之前执行此操作时

public void onCreate(Bundle b){
setTheme(android.R.style.Theme_Dialog);
super.onCreate(b);
}

我认为这是在您的 Activity 上以编程方式设置主题的正确方法,内容正确显示在对话框的屏幕中央,但背景完全是黑色。

我应该使用一些*其他主题吗?我觉得我一定错过了什么。

最佳答案

如果我没理解错的话,你想通过编程设置一个半透明的背景,通过它你可以看到下面的屏幕。如果我没记错的话,Theme_Translucent用于相同的(如果你想以编程方式设置它)。文档说:

public static final int Theme_Translucent

Theme for translucent activities (on API level 10 and lower). That is, windows that allow you to see through them to the windows behind. This sets up the translucent flag and appropriate animations for your windows.

另请查看以下主题:https://groups.google.com/forum/?fromgroups=#!topic/android-developers/vSZHsVWUCqk .这谈论的是与您提出的完全相同的观察结果,但答案仍然不能令人满意。

关于android - 为什么以编程方式设置主题会产生与通过 list 不同的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22521274/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com