0

在我的应用程序中,我使用的是全屏布局,这意味着屏幕超出了屏幕上的按钮(如 nexus 设备上的按钮)。

如果我现在将按钮和其他元素放在布局的底部,它们会干扰导航栏。

我怎样才能让这不会发生?有没有办法指定我的 ui 元素放在屏幕按钮上方,同时保持全屏体验?

4

2 回答 2

1

As noted in the Translucent System Bars, you can add android:fitsSystemWindows="true" (documentation) to ensure that those elements are not placed over system navigation areas.

于 2014-02-24T22:19:08.610 回答
0

Android Developers Training 提供了有关如何使用沉浸式全屏模式的指南。它隐藏了底部系统栏,并允许在该区域使用 ui 元素。如果要向上移动按钮,则底部系统栏会根据设备屏幕分辨率占用一定数量的像素。下面是一些代码,它将返回条形占用的像素数,您可以使用该数字来移动您的 ui 元素。

public int getStatusBarHeight() {
    int result = 0;
    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");

    if (resourceId > 0) {
        result = getResources().getDimensionPixelSize(resourceId);
    }
    return result;
}
于 2014-02-24T22:14:10.230 回答