Android 项目相互重叠移动

Android 项目相互重叠移动,android,layout,Android,Layout,我有一个屏幕,有5个编辑文本,5个按钮,显示正确,如中所示,你可以看到屏幕截图 当我输入文本时,项目会像第二个屏幕截图中那样相互重叠,我如何解决这个问题 这是我的xml代码 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"

我有一个屏幕,有5个编辑文本,5个按钮,显示正确,如中所示,你可以看到屏幕截图

当我输入文本时,项目会像第二个屏幕截图中那样相互重叠,我如何解决这个问题

这是我的xml代码

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent" >

 <ListView
    android:id="@+id/listItems"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/btnGoHome" >

</ListView>

<Button
    android:id="@+id/btnSaveList"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:text="Save" />

<EditText
    android:id="@+id/saveList"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/btnSaveList"
    android:layout_toLeftOf="@+id/btnSaveList"
    android:ems="10"
    android:hint="Create Shopping List" />

<Button
    android:id="@+id/btnViewItems2"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/btnGoHome"
    android:layout_alignBottom="@+id/btnGoHome"
    android:layout_alignParentRight="true"
    android:layout_marginRight="20dp"
    android:text="View Items" />

<Button
    android:id="@+id/btnGoToShop2"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/btnAddItem"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="16dp"
    android:text="Go To Shop" />

<Button
    android:id="@+id/btnGoHome"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/btnGoToShop2"
    android:layout_alignBottom="@+id/btnGoToShop2"
    android:layout_centerHorizontal="true"
    android:text="Home" />

<Button
    android:id="@+id/btnAddItem"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/addQuantity"
    android:layout_marginTop="20dp"
    android:text="Add Item" />

<Spinner
    android:id="@+id/spShoppingList"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/addItem"
    android:layout_alignRight="@+id/btnViewItems2"
    android:layout_below="@+id/btnSaveList"
    android:layout_marginTop="14dp"
    android:ems="10" />

<EditText
    android:id="@+id/addShop"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/addQuantity"
    android:layout_alignLeft="@+id/addQuantity"
    android:layout_marginBottom="18dp"
    android:ems="10"
    android:hint="Add Shop" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/addItem"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/addShop"
    android:layout_alignLeft="@+id/addShop"
    android:layout_marginBottom="15dp"
    android:ems="10"
    android:hint="Add Item" />

<EditText
    android:id="@+id/addQuantity"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:ems="10"
    android:hint="Quantity" />

</RelativeLayout>

尝试在清单中为您的活动添加以下内容(针对您遇到此问题的所有活动):

例如:


从项目清单中,在您的活动标记内,添加代码:

使键盘在启动时可见

android:windowSoftInputMode="stateVisible|adjustPan"
android:windowSoftInputMode="stateHidden|adjustPan"
用于在开始时隐藏键盘

android:windowSoftInputMode="stateVisible|adjustPan"
android:windowSoftInputMode="stateHidden|adjustPan"

在我所有的活动标签中,我有五个活动?不客气。如果答案对你有帮助,别忘了接受它。接受我的答案,因为我是第一个指出答案的人@感谢您的帮助,我尝试了您的和Sir SC,两者都很有效。请接受我指出的第一个@LetmeSuckitBaby的答案