关于清单中的全屏和无标题栏

发布于 2024-11-02 23:34:20 字数 173 浏览 7 评论 0原文

我想将我的应用程序设置为全屏视图。我的想法是使用 FullScreenNoTitlebar 在单个 Activity 中设置它,但我想在整个应用程序的 Manifest XML 文件中设置它,而不是每个 Activity。 ..这可能吗?

帮助我...谢谢。

I want to set my application to full screen view. I got the idea to set it in an individual activity using FullScreen and NoTitlebar, but i want to set it in my Manifest XML file for the whole application not for each activity... Is this possible?

Help me... Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

む无字情书 2024-11-09 23:34:20

要将您的应用程序或任何单个活动显示设置为全屏模式,请将代码插入

<application 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

到应用程序或活动选项卡下的 AndroidManifest.xml 中。

To set your App or any individual activity display in Full Screen mode, insert the code

<application 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

in AndroidManifest.xml, under application or activity tab.

背叛残局 2024-11-09 23:34:20

另一种方法:直接将 windowNoTitlewindowFullscreen 属性添加到主题中(您可以在 res/values/< 中找到 styles.xml 文件) /code> 目录):

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
</style>

在清单文件中,在 application 中指定您的主题

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

Another way: add windowNoTitle and windowFullscreen attributes directly to the theme (you can find styles.xml file in res/values/ directory):

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
</style>

in the manifest file, in application specify your theme

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
泅渡 2024-11-09 23:34:20

如果您的 Manifest.xml 具有默认的 android:theme="@style/AppTheme"

转到 res/values/styles.xml 并更改

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

And the ActionBar 消失了!

If your Manifest.xml has the default android:theme="@style/AppTheme"

Go to res/values/styles.xml and change

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

to

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

And the ActionBar is disappeared!

朮生 2024-11-09 23:34:20

AndroidManifest.xml中,在application标签中设置android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

各个活动可以通过设置自己的主题属性来覆盖默认值。

In AndroidManifest.xml, set android:theme="@android:style/Theme.NoTitleBar.Fullscreen"in application tag.

Individual activities can override the default by setting their own theme attributes.

樱&纷飞 2024-11-09 23:34:20

尝试使用这些主题: Theme.AppCompat.Light.NoActionBar

Mi Style XML 文件看起来像这些并且工作得很好:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

Try using these theme: Theme.AppCompat.Light.NoActionBar

Mi Style XML file looks like these and works just fine:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

雨巷深深 2024-11-09 23:34:20

这似乎是一个老问题,也有一些老答案。我们发现在新项目中执行此操作的最简单方法是编辑 res/values/themes/themes.xml 文件。

操作栏:
将样式元素中的父属性更改为“Theme.MaterialComponents.DayNight.NoActionBar”,如下所示

<style name="Theme.WeatherDisplay" parent="Theme.MaterialComponents.DayNight.NoActionBar">

状态栏:
在 style 元素下添加以下行

<item name="android:windowFullscreen">true</item>

这是生成的 theme.xml

<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.NameOfApp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <!-- Primary brand color. -->
    <item name="colorPrimary">@color/purple_500</item>
    <item name="colorPrimaryVariant">@color/purple_700</item>
    <item name="colorOnPrimary">@color/white</item>
    <!-- Secondary brand color. -->
    <item name="colorSecondary">@color/teal_200</item>
    <item name="colorSecondaryVariant">@color/teal_700</item>
    <item name="colorOnSecondary">@color/black</item>
    <!-- Status bar color. -->
    <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
    <!-- Customize your theme here. -->
    <item name="android:windowFullscreen">true</item>
</style>

This seems to be an old questions with some old answers. We found that the easiest way to do this in a new project is to edit the res/values/themes/themes.xml file.

Actionbar:
Change the parent attribute in the style element to "Theme.MaterialComponents.DayNight.NoActionBar" like this

<style name="Theme.WeatherDisplay" parent="Theme.MaterialComponents.DayNight.NoActionBar">

Status bar:
Add the following line under the style element

<item name="android:windowFullscreen">true</item>

Here is the resulting themes.xml

<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.NameOfApp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <!-- Primary brand color. -->
    <item name="colorPrimary">@color/purple_500</item>
    <item name="colorPrimaryVariant">@color/purple_700</item>
    <item name="colorOnPrimary">@color/white</item>
    <!-- Secondary brand color. -->
    <item name="colorSecondary">@color/teal_200</item>
    <item name="colorSecondaryVariant">@color/teal_700</item>
    <item name="colorOnSecondary">@color/black</item>
    <!-- Status bar color. -->
    <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
    <!-- Customize your theme here. -->
    <item name="android:windowFullscreen">true</item>
</style>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文