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