Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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 Constraintlayout - Fatal编程技术网

Android 当键盘出现时,约束布局列表视图正在移动

Android 当键盘出现时,约束布局列表视图正在移动,android,android-layout,android-constraintlayout,Android,Android Layout,Android Constraintlayout,我正在制作一个应用程序,它将自动显示联系人,然后当在列表视图中单击联系人时,它将直接发送到编辑文本字段。然后他们可以选择是发送信息还是拨打电话号码 问题是,当我单击EditText时,列表视图也会出现,其中包括EditText、按钮和联系人标签。我想这是因为手机的键盘 XML文件 <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="h

我正在制作一个应用程序,它将自动显示联系人,然后当在
列表视图中单击联系人时,它将直接发送到
编辑文本
字段。然后他们可以选择是发送信息还是拨打电话号码

问题是,当我单击
EditText
时,
列表视图也会出现,其中包括
EditText
、按钮和联系人标签。我想这是因为手机的键盘

XML文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/idLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/backgroundwallpaper2"
    android:orientation="vertical">

    <TextView
        android:id="@+id/contacts"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="@string/contacts"
        android:textAlignment="center"
        android:textColor="#000000"
        android:textSize="15pt"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.293" />

    <EditText
        android:id="@+id/number"
        android:layout_width="match_parent"
        android:layout_height="51dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:inputType=""
        android:labelFor="@+id/number"
        android:textColor="#000000"
        android:textSize="25sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.05" />

    <ImageButton
        android:id="@+id/callBtn"
        android:layout_width="57dp"
        android:layout_height="57dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@null"
        android:contentDescription="@string/todo"
        android:text="@string/calls"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.729"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.184"
        app:srcCompat="@drawable/smallcallbtn" />

    <ListView
        android:id="@+id/idList"
        android:layout_width="match_parent"
        android:layout_height="290dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.743"></ListView>

    <ImageButton
        android:id="@+id/imageButton5"
        android:layout_width="57dp"
        android:layout_height="57dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@null"
        android:contentDescription="@string/todo"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.26"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.184"
        app:srcCompat="@drawable/smallmsgbtn" />

</android.support.constraint.ConstraintLayout>

试试这个:

找到包含代码的活动,例如ActivityA,并在AndroidManifest.xml:

<activity
   android:name=".activities.ActivityA"
   android:windowSoftInputMode="adjustPan"> 
</activity>

“adjustPan”活动的主窗口未调整大小,以便为活动腾出空间 软键盘。相反,窗口的内容是 自动平移,使当前焦点不会被 键盘和用户始终可以看到他们正在键入的内容。这是 通常情况下,调整大小不如调整大小,因为用户可能需要 关闭软键盘以接触屏幕上被遮挡的部分并与之交互 窗户


如果希望在任何情况下或当用户单击editText时,屏幕都不应移动布局。您可以将WindowsofInputMode添加到adjustNothing,这将不会移动布局。该行将添加到清单中。下面是清单文件中的代码

<activity android:name=".Activities.Main2Activity"
            android:windowSoftInputMode="adjustNothing">

出于测试目的,我将活动名称用作MainActivity2,在活动中添加android:windowSoftInputMode行。 希望有帮助