1.设置activity无标题
方法一:
在Manifest.xml中为activity增加属性: Android:theme="@android:style/Theme.NoTitleBar"
方法二:
在activity的onCreate()中加入:requestWindowFeature(Window.FEATURE_NO_TITLE);
2.设置activity全屏
方法一:
在Manifest.xml中为activity增加属性: android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
方法二:
代码中增加方法:
public void setFullScreen(boolean isFullScreen) {
if (isFullScreen) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
}
true为设置全屏, false非全屏
3.在android高版本中继承自AppCompatActivity时,上面的做法将失效
这个时候需要修改style属性
<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/purple</item>
</style>
在Manifest.xml中为
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">这个默认的属性修改掉就行了