onTouchEvent() will not be triggered if setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) is invoked

后端 未结 8 662
有刺的猬
有刺的猬 2021-02-01 16:11

I call

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) 

when my app starts to make my app able to displa

8条回答
  •  走了就别回头了
    2021-02-01 16:21

    Have you tried adding code to only show your UI when the state has changed? You have to maintain the last known visibility and only show your UI when you first come into being visible:

    int mLastSystemUiVis;
    
    @Override 
    public void onSystemUiVisibilityChange(int visibility) {
        int diff = mLastSystemUiVis ^ visibility;
        mLastSystemUiVis = visibility;
        if ((diff&SYSTEM_UI_FLAG_VISIBLE) != 0
                && (visibility&SYSTEM_UI_FLAG_VISIBLE) == 0) {
            // DISPLAY YOUR UI
        }
    }
    

    Code sample adopted from the Android docs

提交回复
热议问题