Android显示状态栏,同时启动活动不顺畅

时间:2016-01-12 07:45:00

标签: android statusbar

案例:

当Main2Activity出现时,状态栏会执行跳转。

  • 我该如何避免这种情况?
  • 应该有一些方法来解决这个问题吗?
  • 这与应用主题有关吗?

设备:

Nexus 5,Android 6.0

以下代码:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_main);

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


    private void dealWithSystemUiAction() {
        Intent intent = new Intent();
        intent.setClass(this, Main2Activity.class);
        this.startActivity(intent);
        finish();
    }
}
public class Main2Activity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_main2);


    }
}

enter image description here

0 个答案:

没有答案