Android 黑色空间和向下移动视图

Android 黑色空间和向下移动视图,android,android-layout,android-tablelayout,Android,Android Layout,Android Tablelayout,我有个问题。锁定和解锁手机后,当我聚焦顶部的一个项目时,视图向下移动。当我将一个项目聚焦在底部时,视图移动到起始位置。当我开始一项新的活动并回到家中时,一切都很好 布局代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orie

我有个问题。锁定和解锁手机后,当我聚焦顶部的一个项目时,视图向下移动。当我将一个项目聚焦在底部时,视图移动到起始位置。当我开始一项新的活动并回到家中时,一切都很好

布局代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/settings_bg" >

<TableLayout
    android:id="@+id/base_tiles_table"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:focusable="true"
    android:focusableInTouchMode="true">
</TableLayout>

<include layout="@layout/bottom_navigation" />


当只有一个子元素时,为什么要设置权重?试试这个:

<TableLayout
    android:id="@+id/base_tiles_table"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusable="true"
    android:focusableInTouchMode="true">
</TableLayout>

如果此tablelayout与底部的导航重叠,请执行以下操作:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/settings_bg" >

    <TableLayout
        android:id="@+id/base_tiles_table"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:focusable="true"
        android:focusableInTouchMode="true">
    </TableLayout>

<include layout="@layout/bottom_navigation" />


使用框架布局时,可以使视图/布局重叠。

android:layout\u height=“0dp”将其更改为android:layout\u height=“match\u parent”。如果看不到底部导航,请尝试使用框架布局。或者您也可以使用权重来导航面板。这不仅仅是一个子元素。在include中是另一个子元素(LinearLayout android:layout\u width=“match\u parent”android:layout\u height=“60dp”)。但是包含的元素没有正确设置%权重,因此最好使用框架并将高度设置为mp,在包含的元素上,将minHeight设置为60dp,将高度设置为wrap\u内容。这应该行得通。这在所有观点上都会发生,而不仅仅是现在。问题总是在您解锁屏幕后出现。移动到版面的第一个聚焦元素后,整个版面在屏幕上浮动,直到您开始另一个活动。在活动中,OnTouchVend被覆盖。这可能是问题所在?或者可能是因为它动态地生成一个表?为什么总是在解锁之后?