在android中打开软键盘时,如何将整个布局向上移动

在android中打开软键盘时,如何将整个布局向上移动,android,android-layout,Android,Android Layout,我想移动我的布局,其中有几个视图,所以当用户触摸编辑文本 然后键盘打开,我的布局小部件启动。 我甚至在清单android中使用了代码:WindowsOfInputMode=“adjustPan” 然后android:WindowsOfInputMode=“adjustPan | adjustResize” 没用,请帮帮我 这是我的xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:and

我想移动我的布局,其中有几个视图,所以当用户触摸编辑文本 然后键盘打开,我的布局小部件启动。 我甚至在清单android中使用了代码:WindowsOfInputMode=“adjustPan” 然后android:WindowsOfInputMode=“adjustPan | adjustResize” 没用,请帮帮我
这是我的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"
        android:background="@color/theme_color"
        android:orientation="vertical" >

        <RelativeLayout
            android:id="@+id/relativeLAyoutId"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:focusable="true"
            android:focusableInTouchMode="true" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:src="@drawable/osmosis_label" />

            <EditText
                android:id="@+id/login_screen_username_editText1"
                android:layout_width="220dp"
                android:layout_height="40dp"
                android:layout_below="@+id/imageView1"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="15dp"
                android:ellipsize="start"
                android:ems="10"
                android:gravity="left"
                android:hint="@string/username_editbox_text"
                android:imeOptions="actionNext"
                android:singleLine="true" >

                <requestFocus />
            </EditText>

            <EditText
                android:id="@+id/login_screen_password_editText2"
                android:layout_width="220dp"
                android:layout_height="40dp"
                android:layout_alignLeft="@+id/login_screen_username_editText1"
                android:layout_below="@+id/login_screen_username_editText1"
                android:layout_marginTop="15dp"
                android:ellipsize="start"
                android:ems="10"
                android:gravity="left"
                android:hint="@string/password_editbox_text"
                android:imeOptions="actionDone"
                android:inputType="textPassword"
                android:textColor="@color/login_layout" >
            </EditText>

            <ImageView
                android:id="@+id/login_screen_submit_button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/login_screen_password_editText2"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="15dp"
                android:src="@drawable/log_in"
                android:text="Login" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/login_screen_submit_button1"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="15dp"
                android:text="@string/registered_textview_id"
                android:textColor="@color/grey_color"
                android:textSize="18sp"
                android:textStyle="bold" />
        </RelativeLayout>

    </RelativeLayout>

将其放入oncreate中

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

把这个放在你的oncreate中

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

@你找到解决办法了吗?我也有同样的问题。这个链接可能会对你有所帮助。[见公认答案[1]:@Ashutosh Bansal你找到解决方案了吗?我也有同样的问题。此链接可能对你有所帮助。[见公认答案[1]: