如何将我的活动扩展到屏幕边缘

时间:2016-09-09 08:36:20

标签: java android-layout android-studio android-activity

我正在尝试隐藏状态和导航栏,并将活动扩展到屏幕边缘。我设法隐藏它们并将活动扩展到状态栏而不是导航栏,为什么?如何完全隐藏导航栏?

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

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    View decorView = getWindow().getDecorView();
    int uiOptions;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_LOW_PROFILE;
    } else {
        uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LOW_PROFILE;
    }
    decorView.setSystemUiVisibility(uiOptions);

    setContentView(R.layout.activity_snake);

    //code

}

正如你在图片中看到的这个代码我有这个边框,我希望右侧触摸到屏幕边缘作为另一面

    X = getResources().getDisplayMetrics().widthPixels;
    Y = getResources().getDisplayMetrics().heightPixels;

    pts[0] = 0;
    pts[1] = 0;
    pts[2] = X;
    pts[3] = 0;

    pts[4] = 0;
    pts[5] = 0;
    pts[6] = 0;
    pts[7] = Y;

    pts[8] = X;
    pts[9] = 0;
    pts[10] = X;
    pts[11] = Y;

    pts[12] = 0;
    pts[13] = Y;
    pts[14] = X;
    pts[15] = Y;

    canvas.drawLines(pts, paint);

http://www.sqlservercentral.com/articles/Tally+Table/72993/

0 个答案:

没有答案