Android 如何避免元素重叠在相对屏幕上显示软键盘

Android 如何避免元素重叠在相对屏幕上显示软键盘,android,android-layout,android-softkeyboard,android-xml,android-scrollview,Android,Android Layout,Android Softkeyboard,Android Xml,Android Scrollview,我在这里读了很多帖子,似乎找不到怎么做 我正在尝试创建以下布局xml 在中间我想要一个LinearLayout,在LinearLayout的顶部和开头之间有一些按钮 线性布局在滚动视图中,该滚动视图位于相对视图中 我通过将线性布局和文本视图放在相对视图中来实现这一点。LinearLayout位于父对象的中心,textView位于LinearLayout的上方和父对象的顶部。文本垂直居中 问题是键盘打开时。我只将线性布局放在滚动视图中。 如果我在清单中使用adjustPan,那么什么也不会发生,我

我在这里读了很多帖子,似乎找不到怎么做

我正在尝试创建以下布局xml

在中间我想要一个
LinearLayout
,在
LinearLayout的顶部和开头之间有一些按钮

线性布局滚动视图中,该滚动视图位于相对视图

我通过将
线性布局
文本视图
放在
相对视图
中来实现这一点。
LinearLayout
位于父对象的中心,
textView
位于
LinearLayout
的上方和父对象的顶部。文本垂直居中

问题是
键盘
打开时。我只将
线性布局
放在
滚动视图
中。 如果我在
清单
中使用
adjustPan
,那么什么也不会发生,我无法
滚动
。如果使用
adjustResize
,则
Textview
将显示在
线性布局的顶部,而不是上方。那我怎么做呢?还是不可能?
如果需要,我只希望
linearLayout
可以
滚动。
代码如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/black_overlay"
    android:animateLayoutChanges="true"
    android:hapticFeedbackEnabled="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:fillViewport="true"
        android:layout_centerInParent="true"
        android:id="@+id/scrollView">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="center_horizontal"
            android:id="@+id/mLayout">

            <Button
                android:layout_marginBottom="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="New Match"
                android:id="@+id/btn_newMatch"
                style="@style/ButtonBar"
                android:typeface="monospace"/>

            <Button
                android:layout_marginBottom="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Manage Matches"
                android:id="@+id/btn_manageMatches"
                style="@style/ButtonBar"
                android:typeface="monospace"/>

            <Button
                android:layout_marginBottom="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Manage Teams"
                android:id="@+id/btn_manageTeams"
                style="@style/ButtonBar"
                android:typeface="monospace"/>

            <Button
                android:layout_marginBottom="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Settings"
                android:id="@+id/btn_settings"
                style="@style/ButtonBar"
                android:typeface="monospace"/>

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Logout"
                android:id="@+id/btn_logout"
                style="@style/ButtonBar"
                android:typeface="monospace"/>
        </LinearLayout>
    </ScrollView>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="Name"
        android:typeface="monospace"
        android:layout_above="@id/scrollView"
        android:layout_alignParentTop="true"
        android:gravity="center"
        android:textSize="50dp"
        android:textAppearance="?android:textAppearanceMediumInverse"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"/>
</RelativeLayout>

这是adjustResize当前的外观:

没有键盘:

带键盘:

谁能给我指出正确的方向吗

Thx!!!:)

只要加上这个

android:WindowsOfInputMode=“adjustPan | stateHidden”


以查看清单中的活动声明

为了防止显示键盘时my
RelativeLayout
中视图的垂直重叠,只需添加一个边距即可解决问题

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true"
    android:background="@android:color/darker_gray"
    android:hapticFeedbackEnabled="true" >

    <EditText
        android:id="@+id/etName"
        android:layout_width="60dp"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"
        android:gravity="center" />

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/etName"
        android:layout_centerInParent="true"
        android:fillViewport="true" >

        <LinearLayout
            android:id="@+id/mLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:orientation="vertical" >

            <Button
                android:id="@+id/btn_newMatch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:text="New Match"
                android:typeface="monospace" />

            <Button
                android:id="@+id/btn_manageMatches"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:text="Manage Matches"
                android:typeface="monospace" />

            <Button
                android:id="@+id/btn_manageTeams"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:text="Manage Teams"
                android:typeface="monospace" />

            <Button
                android:id="@+id/btn_settings"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:text="Settings"
                android:typeface="monospace" />

            <Button
                android:id="@+id/btn_logout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Logout"
                android:typeface="monospace" />
        </LinearLayout>
    </ScrollView>

</RelativeLayout>

android:layout\u marginTop=“25dp”

通过调整面板,屏幕不会调整大小。键盘位于布局顶部,因此布局不会重叠,但也不会滚动。请详细说明您的问题。。!你到底想要什么?我真正想要的是将布局调整到最小高度,使任何内容都不会重叠并可滚动。但是读了很多书之后,我认为这是不可能的。所以我希望它是可滚动的,以避免我在图像上显示的重叠。
 android:windowSoftInputMode="adjustResize|stateHidden"