[英]Creates a full screen activity but retains the notification bar
在你的主題中:
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
在你的活動onCreate:
Window window = getWindow();
WindowManager.LayoutParams winParams = window.getAttributes();
winParams.flags &= ~WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
window.setAttributes(winParams);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
刪除getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
您的代碼中的這一行,只需將更改為您的活動樣式。
<style name="LoginTheme" 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/colorAccent</item>
</style>
的Manifest.xml
<activity android:name=".Login"
android:theme="@style/LoginTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
把這段代碼放在setContentView()
上面
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.