Android 4.4 — Translucent status/navigation bars — fitsSystemWindows/clipToPadding don't work through fragment transactions

前端 未结 8 2097
余生分开走
余生分开走 2021-01-30 11:30

When using the translucent status and navigation bars from the new Android 4.4 KitKat APIs, setting fitsSystemWindows=\"true\" and clipToPadding=\"false\"

相关标签:
8条回答
  • 2021-01-30 12:06

    I encountered the same problem. When I replace Fragment. The 'fitsSystemWindows' doesn't work.

    I fixed by code add to your fragment

    @Override
    public void onViewCreated(final View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        AndroidUtil.runOnUIThread(new Runnable() {
            @Override
            public void run() {
                ((ViewGroup) getView().getParent()).setFitsSystemWindows(true);
            }
        });
    }
    
    0 讨论(0)
  • 2021-01-30 12:07

    I have resolve this question in 4.4

    if(test){
        Log.d(TAG, "fit true ");
        relativeLayout.setFitsSystemWindows(true);
        relativeLayout.requestFitSystemWindows();
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }else {
        Log.d(TAG, "fit false");
        relativeLayout.setFitsSystemWindows(false);
        relativeLayout.requestFitSystemWindows();
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    
    0 讨论(0)
提交回复
热议问题