【问题标题】:Android App Layout Alignment issue with LG Nexus 4 and Moto XLG Nexus 4 和 Moto X 的 Android 应用布局对齐问题
【发布时间】:2015-07-18 18:51:40
【问题描述】:

我遇到了 LG Nexus 4 和 Moto X 设备的布局对齐问题。我想将“关于”按钮与菜单底部对齐,但在上面的设备中,导航按钮覆盖了它。 看截图:

Nexus 4 屏幕截图(右)其他设备(左)

这是我的代码 sn-p。

//Upper Layout
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1">
</FrameLayout>
//About Us button

可能的解决方案 解决此问题的方法是隐藏导航按钮托盘。但我对此并不满意。

注意:以上截图是在不同时间段截取的,请忽略版面的边距/尺寸。

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    您可以根据导航栏的高度重新调整底部填充。

    int additionalPadding = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Resources resources = getResources();
        int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
        if (resourceId > 0) {
            additionalPadding = resources.getDimensionPixelSize(resourceId);
        }
    }
    

    现在您可以使用将此附加填充添加到视图底部。

    【讨论】:

      猜你喜欢
      • 2014-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-08
      • 1970-01-01
      相关资源
      最近更新 更多