為了制作全屏活動。 到目前為止,我已經試過了,如下所示:
requestWindowFeature(Window.FEATURE_NO_TITLE)
在Activity的setContentView()方法之前。
還嘗試添加以下幾行 :
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
視窗經理.LayoutParams.FLAG_FULLSCREEN)
但是它沒有作業。然后,我移到了manifest,并嘗試了以下方法:
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
<activity。
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
android:name="SplashActivity"
android:screenOrientation="portrait"/span>>
<intent-filter>/span>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/span> />
</intent-filter>
</activity>/span>
而我在上面嘗試的樣式如下:
<style name="Theme. AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
<item name="windowNoTitle"/span>> true</item>
<item name="windowActionBar" > false</item>
<item name="android: windowFullscreen">true</item>/span>
<item name="android: windowContentOverlay">@null</item>/span>
<item name="android: windowTranslucentStatus">true</item>
<item name="android: windowTranslucentNavigation">true</item>/span>
</style>>
是的,在我的布局中,根標簽如下:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"/span>
xmlns:app="http://schemas.android.com/apk/res-auto"。
android:layout_width="match_parent"。
android:layout_height="match_parent"。
android:fitsSystemWindows="true"。
android:background="@drawable/bg_layout_screen">
意思是使用android:fitsSystemWindows="true"
現在,問題是它在全屏活動中不可見。 這個問題的截圖如下:
[![輸入圖片]]
[!
[![在此輸入圖片描述][1]][1][![在此輸入圖片描述][2]]
但是,問題仍然是下面的圖片。
第一張圖片。 [1]: https://i.stack.imgur.com/fbJ2l.jpg
第二張圖片。 [2]: https://i.stack.imgur.com/ZTpgw.jpg
黑色是在清單中加入這一行 :
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
請指導。可能是什么問題?謝謝。
uj5u.com熱心網友回復:
根據你的第一張圖片,你只需將狀態欄的顏色改為透明的。 要做到這一點,請參考下面的帖子
。
<
希望這個帖子對你有幫助 :) uj5u.com熱心網友回復: 你可以使用 示例:
標籤: 上一篇:影像視圖在運行時不渲染
下一篇:如何通過錯誤資訊找到屬性的id
onWindowFocusChanged()和View decorView = getWindow().getDecorView();然后設定SystemUiVisibility。
//set full screen
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus)。
if (hasFocus) {
hideSystemUI()。
}
}
private void hideSystemUI() {
View decorView = getWindow().getDecorView() 。
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY。
//當系統欄隱藏和顯示時,內容不會調整大小。。
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE。
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION。
//隱藏導航欄和狀態欄。
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION。
View.SYSTEM_UI_FLAG_FULLSCREEN.
);
