Activity和AppCompatActivity全屏设置

来源:互联网 发布:python prolog 编辑:程序博客网 时间:2024/05/22 04:32

Activity全屏设置

一、通过代码

setContentView之前执行:

requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐藏状态栏

二、调用Android自带的Theme

直接在AndroidManifest.xml中需要全屏显示的Activity属性中添加
android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”

三、自己定义全屏Theme

在style.xml文件中定义theme(如果没有style.xml,在res/values目录下创建)

<resources>     <style name="theme_fullScreen" parent="android:Theme.Black">        <item name="android:windowNoTitle">true</item>            <item name="android:windowFullscreen">true</item>          </style> </resources>

直接在AndroidManifest.xml中需要全屏显示的Activity属性中添加
android:theme=”@style/Theme.NoTitle_FullScree”

AppCompatActivity全屏设置

<style name="theme_fullScreen" parent="Theme.AppCompat.NoActionBar">        <item name="android:windowFullscreen">true</item>        <item name="android:windowNoTitle">true</item>        <item name="windowActionBar">false</item>    </style>
直接在AndroidManifest.xml中需要全屏显示的**AppCompatActivity属性**中添加

android:theme=”@style/Theme.NoTitle_FullScree”

0 0
原创粉丝点击