gpt4 book ai didi

android - 使用 Theme.AppCompat.Dialog 时操作栏看起来被切断了

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:44:08 27 4
gpt4 key购买 nike

我希望让我的一个 Activity 看起来像一个对话框,并为此使用了 Theme.AppCompat.Dialog 主题,但这使得它的操作栏看起来很糟糕(见下文)。

现在背景被剪切成标题字符串的长度,我找不到任何主题属性来修复它。(

如何避免?

styles.xml相关部分:

<style name="DeviceListTheme" parent="Theme.AppCompat.Dialog">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

我使用以下代码开始 Activity :

Intent intent = new Intent(this, DeviceListActivity.class);
startActivityForResult(intent, REQUEST_CONNECT_DEVICE);

最佳答案

首先,当我遇到这个问题时,我尝试使用 supportRequestWindowFeature(Window.FEATURE_NO_TITLE); 但这对我不起作用并且没有任何效果。

删除对话框 Activity 顶部栏的替代方法是创建自定义样式并将其应用于该 Activity 。

styles.xml 中,像这样创建一个新样式:

<style name="MyCustomDialog" parent="Base.Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>

现在,在 AndroidManifest.xml 中,将 android:theme="@style/MyCustomDialog" 添加到您的 Activity 中。

当然,MyCustomDialog 可以重命名为任何你想要的。

关于android - 使用 Theme.AppCompat.Dialog 时操作栏看起来被切断了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28582339/

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