Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.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 studio布局将变为空白_Android_Android Studio_Android Layout - Fatal编程技术网

当我在多行文本中输入文本时,Android studio布局将变为空白

当我在多行文本中输入文本时,Android studio布局将变为空白,android,android-studio,android-layout,Android,Android Studio,Android Layout,在这个编辑文本视图中,如果我输入一个单词,它会变成这样 XMl 我已经添加了整个XMl文件 我想在我的文本字段中输入文本,但我无法这样做,我以前尝试过我的解决方案,但这个问题仍然是相同的您的EditText没有id名称,并且您缺少宽度属性的单位dp中的d。此外,当您约束它时,不能在另一个视图的id名称中包含+符号用于新视图,而不是引用现有视图。做这些改变,你应该会没事的 编辑:如果您添加了xml代码,我可以确定具体的更改,但如果您只共享图像,我就无法做到这一点 编辑2: 当你使用从左到右的布局时

在这个编辑文本视图中,如果我输入一个单词,它会变成这样

XMl

我已经添加了整个XMl文件
我想在我的文本字段中输入文本,但我无法这样做,我以前尝试过我的解决方案,但这个问题仍然是相同的

您的EditText没有id名称,并且您缺少宽度属性的单位dp中的d。此外,当您约束它时,不能在另一个视图的id名称中包含+符号用于新视图,而不是引用现有视图。做这些改变,你应该会没事的

编辑:如果您添加了xml代码,我可以确定具体的更改,但如果您只共享图像,我就无法做到这一点

编辑2: 当你使用从左到右的布局时,左边距和边距开始,或者右边距和边距结束是多余的,因为它们是相同的。我没有破坏你的布局,但我删除了。另外,我将高度包装到了textview的内容中

<?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:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:text="TextView"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <EditText
        android:id="@+id/edittext"
        android:layout_width="215dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:autofillHints=""
        android:ems="10"
        android:inputType="textMultiLine"
        android:scrollbarSize="8dp"
        android:scrollbars="horizontal|vertical"
        app:layout_constraintBottom_toTopOf="@id/button2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/textView"
        app:layout_constraintTop_toBottomOf="@id/textView"
        tools:ignore="HardcodedText"
        tools:targetApi="o" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="12dp"
        android:text="OK"
        app:layout_constraintBaseline_toBaselineOf="@id/button2"
        app:layout_constraintEnd_toStartOf="@id/button2" />

</android.support.constraint.ConstraintLayout>

现在对我来说还没有失败。如果它仍然适用于您,那么很可能您给其他版面的文本视图赋予了相同的名称每个视图都应该有一个唯一的名称,因为所有内容都存储在同一个R文件中。

请添加layout.xml而不是照片好吗?请添加layout.xml文件添加layout.xml文件添加xml图像请不要使用图像而不是实际代码,你可以很容易地复制和粘贴你的代码在这里我可以在邮件或其他地方与你联系吗?我是这个社区的新成员,在上传我的代码时遇到问题code@kathanpatel打开xml文件,选择所有代码并将其复制到Control+A for windows或Cmd+A for mac,然后Control+C for windows或Cmd+C for mac。然后你来到这里,通过粘贴复制的文本控件+V(windows)或Cmd+V(mac)来编辑你的文章。然后选择复制的所有代码,并对windows或mac执行Control+K或Cmd+K,将其格式化为代码并发布。即使失败了,也要复制粘贴整个内容,我会将其格式化。谢谢我能够发布我的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:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:text="TextView"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <EditText
        android:id="@+id/edittext"
        android:layout_width="215dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:autofillHints=""
        android:ems="10"
        android:inputType="textMultiLine"
        android:scrollbarSize="8dp"
        android:scrollbars="horizontal|vertical"
        app:layout_constraintBottom_toTopOf="@id/button2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/textView"
        app:layout_constraintTop_toBottomOf="@id/textView"
        tools:ignore="HardcodedText"
        tools:targetApi="o" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        android:text="Button"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="12dp"
        android:text="OK"
        app:layout_constraintBaseline_toBaselineOf="@id/button2"
        app:layout_constraintEnd_toStartOf="@id/button2" />

</android.support.constraint.ConstraintLayout>