Advertisement
SenpaiZero

Transparent status bar and action bar

Mar 12th, 2024
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. public void removeActionbar()
  2.     {
  3.         try
  4.         {
  5.             ((AppCompatActivity)activity).getSupportActionBar().hide();
  6.         } catch (Exception ex)
  7.         {
  8.             try {
  9.                 activity.getActionBar().hide();
  10.             } catch (Exception exx)
  11.             {
  12.                 Log.e("Action Bar", exx.getMessage());
  13.             }
  14.         }
  15.     }
  16.  
  17.     public void transparentStatusBar()
  18.     {
  19.         try {
  20.             Window window = activity.getWindow();
  21.             window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  22.             window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  23.             window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
  24.             window.setStatusBarColor(Color.TRANSPARENT);
  25.         } catch (Exception ex)
  26.         {
  27.             Log.e("Transparent Status Bar", ex.getMessage());
  28.         }
  29.  
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement