android appcompatactivity和activity,Android教程-全屏姿势-Activity和AppCompatActivity

Activity全屏姿势

Java代码设置

requestWindowFeature(Window.FEATURE_NO_TITLE);//这行代码一定要在setContentView之前,不然会闪退

Window window = getWindow();

window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

主题设置

自带可设置全屏的主题有:

@android:style/Theme.NoTitleBar.Fullscreen

@android:style/Theme.Black.NoTitleBar.Fullscreen

@android:style/Theme.Holo.NoActionBar.Fullscreen

@android:style/Theme.Light.NoTitleBar.Fullscreen

@android:style/Theme.Material.NoActionBar.Fullscreen

@android:style/Theme.Translucent.NoTitleBar.Fullscreen

@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen

@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen

@android:style/Theme.Holo.Light.NoActionBar.Fullscreen

@android:style/Theme.Material.Light.NoActionBar.Fullscreen

@android:style/Theme.DeviceDefault.Light.NoActionBar.Fullscreen

AppCompatActivity全屏姿势

Java代码设置

getSupportActionBar().hide();

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

主题设置

@color/colorPrimary

@color/colorPrimaryDark

@color/colorAccent

true

true

false

小知识点:

true 可以实现去title,但是android还有一种 true,使用后者替代前者不可以起到去title的作用

false也有这样的形式: false

但是 true没有 true

你可能感兴趣的:(android)