AppCompatActivity中设置去标题和全屏

在AppCompatActivity(或ActionBarActivity)中不能再用requestWindowFeature(Window.FEATURE_NO_TITLE) 的方法设置去掉标题(早已淘汰)。之后直接在在style.xml里更改主题:android

<resources>

    <!-- Base application theme -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

    <!-- Activity无标题栏+全屏 开始-->
    <style name="NoTitle" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowNoTitle">true</item>
        <!-- 兼容API 7-->
        <item name="android:windowActionBar">false</item>
        <!-- Activity全屏 开始-->
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>
    <!-- Activity无标题栏 结束-->

</resources>

而后在AndroidManifest.xml里将android:theme更改成android:theme="@style/NoTitle"便可。app

相关文章
相关标签/搜索