简体   繁体   English

Android导航栏覆盖了我的视图

[英]Android Navigation Bar overlaying my view

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. 我在Nexus等设备上遇到Android导航栏的问题。只需在所有没有硬件菜单按钮的设备上。

Let me explain the issue in more details. 让我更详细地解释一下这个问题。

I have an application where there are 3 parts. 我有一个应用程序,其中有3个部分。 Content, ActionBar and bottom panel with a SeekBar. 内容,ActionBar和带有SeekBar的底部面板。

在此输入图像描述

ActionBar and bottom panel with a SeekBar are overlaying the content. 带有SeekBar的ActionBar和底部面板覆盖了内容。 Everytime I click on the content the ActionBar and bottom panel with a SeekBar disappear. 每次我点击内容时,ActionBar和带有SeekBar的底部面板都会消失。 Which works exactly the way it has to work. 这完全符合它的工作方式。 Here is a fragment of a code I use for hiding system UI: 这是我用于隐藏系统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: 在我的活动的onCreate方法中,我有这段代码:

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. 但是,当我在具有Android导航栏的设备上启动应用程序时,使用SeekBar显示底部面板时出现问题。 Simply, the Android Navigation Bar overlays the bottom panel with a SeekBar. 简单来说,Android导航栏使用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. 但每次我点击内容时,Android导航栏都会随着ActionBar和带有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. 所以,问题在于,每当有人想在NEXUS等设备上使用底层面板和SeekBar时,他/她将无法使用它,因为它隐藏在Android导航栏下。

Could anybody help me with solving this issue? 有人可以帮我解决这个问题吗? Thank you all in advance. 谢谢大家。

最后,我用属性fitsSystemWindows = true解决了它。

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. 当你设置这也可能发生android:layout_gravity="center"android:layout_marginTop="30dp"我通过塞汀固定的类似问题android:layout_gravity="center_horizontal"来代替。 Then marginTop works as assumed. 然后marginTop按照假设工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM