第一种方法,在代码里面直接写。
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
需要在setContentView方法调用之前设置。
第二种方法,定义一个主题,在styles.xml里面
- <stylename="Theme.NoTitle_FullScreen">
- <itemname="android:windowNoTitle">true</item>
- <itemname="android:windowFullscreen">true</item>
- </style>
- </resources>
在代码中动态设置是否全屏与清除
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
透明
<style name="translucent">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
</style>
或者 theme=“android:style/Theme.Translucent"