Recent

Author Topic: LAMW - no status bar n full transparent trick  (Read 199 times)

Mongkey

  • Sr. Member
  • ****
  • Posts: 278
LAMW - no status bar n full transparent trick
« on: September 30, 2022, 03:59:12 am »
Code: Pascal  [Select][+][-]
  1.  
  2. styles.xml
  3.         <item name="android:statusBarColor">@android:color/transparent</item>
  4.         <item name="android:windowNoTitle">true</item>
  5.         <item name="android:windowTranslucentStatus">true</item>
  6.         <item name="android:windowTranslucentNavigation">true</item>
  7.  
  8.  
  9. app.java
  10. on create{
  11.       transparentStatusAndNavigation();
  12.     }
  13.  
  14.     private void transparentStatusAndNavigation() {
  15.         //make full transparent statusBar
  16.         if (android.os.Build.VERSION.SDK_INT >= 19 && android.os.Build.VERSION.SDK_INT < 21) {
  17.             setWindowFlag(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
  18.                     | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, true);
  19.         }
  20.         if (android.os.Build.VERSION.SDK_INT >= 19) {
  21.             getWindow().getDecorView().setSystemUiVisibility(
  22.                     View.SYSTEM_UI_FLAG_LAYOUT_STABLE
  23.                             | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
  24.                             | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
  25.             );
  26.         }
  27.         if (android.os.Build.VERSION.SDK_INT >= 21) {
  28.             setWindowFlag(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
  29.                     | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, false);
  30.             getWindow().setStatusBarColor(Color.TRANSPARENT);
  31.             getWindow().setNavigationBarColor(Color.TRANSPARENT);
  32.         }
  33.     }
  34.  
  35.     private void setWindowFlag(final int bits, boolean on) {
  36.         Window win = getWindow();
  37.         WindowManager.LayoutParams winParams = win.getAttributes();
  38.         if (on) {
  39.             winParams.flags |= bits;
  40.         } else {
  41.             winParams.flags &= ~bits;
  42.         }
  43.         win.setAttributes(winParams);
  44.     }
  45.  

 

TinyPortal © 2005-2018