Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当键盘出现时,布局会改变_Android_Android Layout_Android Keypad - Fatal编程技术网

Android 当键盘出现时,布局会改变

Android 当键盘出现时,布局会改变,android,android-layout,android-keypad,Android,Android Layout,Android Keypad,我已经创建了一个包含编辑框、文本字段、按钮和图像等的布局。但是当我尝试在编辑框中键入内容时,键盘出现,布局发生了可怕的变化。我如何解决这个问题 在键盘出现之前 键盘出现后 我的布局 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="ma

我已经创建了一个包含编辑框、文本字段、按钮和图像等的布局。但是当我尝试在编辑框中键入内容时,键盘出现,布局发生了可怕的变化。我如何解决这个问题

在键盘出现之前

键盘出现后

我的布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/grey"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/contactus_heading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="@string/cinema_contactus"
        android:textColor="#000000"
        android:textStyle="bold"
        android:textSize="20dp" />

    <EditText
        android:id="@+id/contactus_name_edittext"
        android:layout_width="340dp"
        android:layout_height="40dp"
        android:layout_above="@+id/contactus_email_edittext"
        android:layout_alignLeft="@+id/contactus_email_edittext"
        android:layout_alignRight="@+id/contactus_email_edittext"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="20dp"
        android:background="@drawable/rounded_edittext"
        android:ems="10"
        android:hint="Name"
        android:textSize="12sp" />

    <EditText
        android:id="@+id/contactus_email_edittext"
        android:layout_width="340dp"
        android:layout_height="40dp"
        android:layout_above="@+id/contactus_message_edittext"
        android:layout_marginBottom="20dp"
        android:layout_toRightOf="@+id/fax"
        android:background="@drawable/rounded_edittext"
        android:ems="10"
        android:hint="E-mail"
        android:textSize="12sp" />

    <EditText
        android:id="@+id/contactus_message_edittext"
        android:layout_width="340dp"
        android:layout_height="115dp"
        android:layout_above="@+id/contactus_submit_button"
        android:layout_alignLeft="@+id/contactus_email_edittext"
        android:layout_alignRight="@+id/contactus_email_edittext"
        android:layout_marginBottom="20dp"
        android:background="@drawable/rounded_edittext"
        android:ems="10"
        android:gravity="top|left"
        android:hint="Message"
        android:textSize="12sp" />

    <Button
        android:id="@+id/contactus_submit_button"
        android:layout_width="125dp"
        android:layout_height="40dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@drawable/mybutton"
        android:text="@string/submit"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="20dp"
        android:textSize="14dp" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
    </LinearLayout>

    <ImageView
        android:id="@+id/emailedit"
        android:layout_width="45dp"
        android:layout_height="40dp"
        android:layout_alignTop="@+id/contactus_email_edittext"
        android:layout_toLeftOf="@+id/contactus_email_edittext"
        android:src="@drawable/emailtop" />

    <ImageView
        android:id="@+id/nameedit"
        android:layout_width="45dp"
        android:layout_height="40dp"
        android:layout_alignTop="@+id/contactus_name_edittext"
        android:layout_toLeftOf="@+id/contactus_name_edittext"
        android:src="@drawable/nametop" />

    <ImageView
        android:id="@+id/messageedit"
        android:layout_width="45dp"
        android:layout_height="115dp"
        android:layout_alignTop="@+id/contactus_message_edittext"
        android:layout_toLeftOf="@+id/contactus_message_edittext"
        android:src="@drawable/messagetop" />

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/contactus_submit_button"
        android:layout_below="@+id/contactus_email_edittext"
        android:orientation="horizontal" >
    </LinearLayout>



    <ImageView
        android:id="@+id/fax"
        android:layout_width="14dp"
        android:layout_height="14dp"
        android:layout_alignTop="@+id/contactus_telephone2"
        android:layout_toLeftOf="@+id/contactus_telephone2"
        android:layout_marginTop="3dp"
        android:src="@drawable/fax" />

    <ImageView
        android:id="@+id/email"
        android:layout_width="14dp"
        android:layout_height="14dp"
        android:layout_alignTop="@+id/contactus_email"
        android:layout_toLeftOf="@+id/contactus_email"
        android:layout_marginTop="3dp"
        android:src="@drawable/message" />

    <ImageView
        android:id="@+id/telephone"
        android:layout_width="14dp"
        android:layout_height="14dp"
        android:layout_alignTop="@+id/contactus_telephone1"
        android:layout_toLeftOf="@+id/contactus_telephone1"
        android:layout_marginTop="3dp"
        android:src="@drawable/call" />

    <ImageView
        android:id="@+id/addresspointer"
        android:layout_width="14dp"
        android:layout_height="14dp"
        android:layout_alignLeft="@+id/telephone"
        android:layout_alignTop="@+id/contactus_address"
        android:layout_marginTop="3dp"
        android:src="@drawable/pointer" />

    <TextView
        android:id="@+id/contactus_address"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/contactus_submit_button"
        android:layout_centerHorizontal="true"
        android:text="@string/cinema_contactus_address"
        android:textColor="#000000"
        android:lineSpacingExtra="5dp"
        android:textSize="14sp"
        android:layout_marginTop="25dp" />

    <TextView
        android:id="@+id/contactus_telephone1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/contactus_address"
        android:layout_below="@+id/contactus_address"
        android:text="@string/cinema_contactus_telephone1"
        android:textColor="#000000"
        android:layout_marginTop="5dp"
        android:textSize="14sp" />

    <TextView
        android:id="@+id/contactus_telephone2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/telephone"
        android:layout_toRightOf="@+id/telephone"
        android:text="@string/cinema_contactus_telephone2"
        android:textColor="#000000"
        android:layout_marginTop="5dp"
        android:textSize="14sp" />

    <TextView
        android:id="@+id/contactus_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/contactus_telephone2"
        android:layout_below="@+id/contactus_telephone1"
        android:text="@string/cinema_contactus_email"
        android:textColor="#000000"
        android:layout_marginTop="5dp"
        android:textSize="14sp" />



</RelativeLayout>

确定找到了答案

我只需要在清单中的活动中添加以下内容

android:WindowsOfInputMode=“adjustPan”

试试这个

内部onCreate写入

getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

谢谢。但我刚刚在我的活动清单中添加了安卓:windowSoftInputMode=“adjustPan”,它似乎做到了这一点