0

I have the following code:

public class MainActivity extends AppCompatActivity {

boolean visible = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getSupportActionBar().hide();

    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            changeStatusBarVisibility();
        }
    });
}

private void changeStatusBarVisibility() {
    int flags = visible ? View.SYSTEM_UI_FLAG_FULLSCREEN : 0;
    getWindow().getDecorView().setSystemUiVisibility(flags);
    visible = !visible;
}}

In my case I need to switch fullscreen mode (enable / disable). This code works. But as you can see my activity is jumping, it looks bad. How to enable/disable fullscreen mode smoothly?

This code also works without juimping on devices without cutouts

cosinusx
  • 35
  • 1
  • 7
  • See if this works: https://stackoverflow.com/questions/37577015/make-an-android-activity-full-screen-over-a-button – denvercoder9 Apr 02 '19 at 17:43
  • Possible duplicate of [Make an android activity full screen over a button](https://stackoverflow.com/questions/37577015/make-an-android-activity-full-screen-over-a-button) – denvercoder9 Apr 02 '19 at 17:51
  • I have removed the gif - it's not there any more. Please use Stack Overflow's embedded image feature to host gifs and images in the future - this protects it from various issues such as server removal or issues related to the host itself that's out of SO's control. – Zoe Apr 02 '19 at 18:41

0 Answers0