【问题标题】:Android window fullscreen with no action barAndroid 窗口全屏,没有操作栏
【发布时间】:2018-08-31 14:36:09
【问题描述】:

我通过编写以下代码使我的应用全屏显示,没有标题

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

但我可以像往常一样从顶部打开操作栏和通知栏。 有什么办法永远不显示顶部操作栏。

全屏应用:

可见状态栏:

当我从顶部移动状态栏触摸并向下滑动时,它就会变得可见。如何阻止它?

更新:

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sampleapp">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTask"
            android:stateNotNeeded="true"
            android:theme="@style/AppTheme.Wallpaper">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".LockScreenActivity" />
    </application>
</manifest>

styles.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>

    <!-- THIS IS THE MAIN THEME -->
    <style name="AppTheme.Wallpaper" parent="@style/Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowShowWallpaper">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
    </style>
</resources>

【问题讨论】:

标签: android


【解决方案1】:

在 style.xml 中使用这段代码

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

【讨论】:

    【解决方案2】:

    试试这个!

       @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
    
                this.requestWindowFeature(Window.FEATURE_NO_TITLE);
                this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
                setContentView(R.layout.activity_main);
        }
    

    在 style.xml 中:

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

    在清单应用程序标签中:

    android:theme="@style/AppTheme"
    

    【讨论】:

    • 没有。向下滚动时该栏仍然出现。
    • 更新你的清单删除这一行 android:theme="@style/AppTheme.Wallpaper"
    猜你喜欢
    • 2011-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-04
    • 1970-01-01
    相关资源
    最近更新 更多