2012-12-18 21 views
0

我遇到問題。當我將物品放在頂部時鎖定和解鎖手機後,視圖向下移動。當我將項目聚焦在底部時,視圖移動到開始位置。當我開始新的活動並回到家時,一切都很好。黑色空間和向下移動視圖

enter image description here

佈局代碼:

<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" /> 

+0

android:layout_height =「0dp」將其更改爲android:layout_height =「match_parent」。如果您無法看到底部導航,請嘗試使用框架佈局。或者你也可以使用重量導航面板。 – kumar

回答

0

你爲什麼要設置時的重量只有1個元素?試試這個:

<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" /> 

當您使用的FrameLayout,可以使視圖/佈局重疊。

+0

這不只是一個子元素。在include中是另一個孩子(LinearLayout android:layout_width =「match_parent」 android:layout_height =「60dp」)。 – monawi

+0

但包含的元素沒有設置權重%,所以最好使用框架並將高度設置爲mp並在包含的元素上設置minHeight爲60dp並將高度設置爲wrap_content。這應該工作。 – lokoko

+0

這是發生在所有的意見,而不僅僅是現在。解鎖屏幕後,問題始終存在。移動到佈局的第一個聚焦元素後。 – monawi