Android Navigation Bar overlaying my view

☆樱花仙子☆ 提交于 2019-12-12 08:34:41

问题


I have an issue with Android Navigation Bar on devices like Nexus etc. Simply at all devices, which do not have the hardware menu button.

Let me explain the issue in more details.

I have an application where there are 3 parts. Content, ActionBar and bottom panel with a SeekBar.

ActionBar and bottom panel with a SeekBar are overlaying the content. Everytime I click on the content the ActionBar and bottom panel with a SeekBar disappear. Which works exactly the way it has to work. Here is a fragment of a code I use for hiding system UI:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {                
            decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE);
} else {                
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    actionBar.hide();
}
findViewById(R.id.read_book_bottom_bar).setVisibility(View.GONE);

In onCreate method of my activity, I have this piece of code:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {            
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);          
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN);   
}

However, when I launch the application on devices with Android Navigation Bar, there is a problem with displaying the bottom panel with a SeekBar. Simply, the Android Navigation Bar overlays the bottom panel with a SeekBar. Here is a screenshot:

But everytime I click on the content, the Android Navigation Bar disappears along with the ActionBar and the bottom panel with the SeekBar. So, the issue is, that everytime somebody would like to use the bottom panel with the SeekBar on devices like NEXUS, he/she would not be able to use it, because it's hidden under the Android Navigation Bar.

Could anybody help me with solving this issue? Thank you all in advance.


回答1:


Finally, I solved it with attribute fitsSystemWindows = true.




回答2:


That may also happen when you set android:layout_gravity="center" and android:layout_marginTop="30dp" I fixed similar issue by seting android:layout_gravity="center_horizontal" instead. Then marginTop works as assumed.



来源:https://stackoverflow.com/questions/25471113/android-navigation-bar-overlaying-my-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!