1

Это мой XML-файл, который определяет два EditText компоненты и две TextView компоненты, но когда второй EditText компонентаAndroid TextView ниже EditText исчезают

android:inputType="textMultiLine" 

заполнить весь экран, две TextView компонентов будут исчезать, почему это?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

<EditText 
    android:id="@+id/note_title" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="22dp" 
    android:layout_marginRight="16dp" 
    android:layout_marginTop="16dp" 
    android:hint="@string/title_hint" 
    android:textStyle="bold" 
    android:textSize="20sp" 
    android:textColorHint="@color/titleColorHint" 
    android:textColor="@color/colorText" 
    android:inputType="text" 
    android:background="@null"/> 

<EditText 
    android:id="@+id/note_text" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="22dp" 
    android:layout_marginRight="16dp" 
    android:layout_marginTop="10dp" 
    android:hint="@string/text_hint" 
    android:layout_below="@id/note_title" 
    android:textSize="16sp" 
    android:textColorHint="@color/textColorHint" 
    android:textColor="@color/colorText" 
    android:inputType="textMultiLine" 
    android:background="@null"/> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="22dp" 
    android:layout_marginRight="16dp" 
    android:layout_marginTop="20dp" 
    android:text="@string/dotted_line" 
    android:textSize="11sp" 
    android:textColor="@color/dottedLineColor"/> 

<TextView 
    android:id="@+id/note_date" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginRight="16dp" 
    android:layout_marginTop="20dp" 
    android:layout_gravity="bottom|end" 
    android:text="Note date" 
    android:textColor="@color/dateTextColor" 
    android:textSize="11sp"/> 

</LinearLayout> 
+0

Вы должны установить высоту, если многострочного редактирования текста или сделать вид родительского прокрутки, так что экран прокручивать. TextViews подталкиваются под экран. – drulabs

+0

Спасибо. Я пробовал ответить ниже. –

ответ

0

По умолчанию все виджеты EditText в Android являются многоуровневыми.

Вот некоторые примеры кода:

<EditText 
    android:inputType="textMultiLine" <!-- Multiline input --> 
    android:lines="8" <!-- Total Lines prior display --> 
    android:minLines="6" <!-- Minimum lines --> 
    android:gravity="top|left" <!-- Cursor Position --> 
    android:maxLines="10" <!-- Maximum Lines --> 
    android:layout_height="wrap_content" <!-- Height determined by content --> 
    android:layout_width="fill_parent" <!-- Fill entire width --> 
    android:scrollbars="vertical" <!-- Vertical Scroll Bar --> 
/> 
+0

Спасибо за ваш ответ. Я пробовал это, и это сработало. Теперь есть еще один вопрос: как заставить эти четыре группы прокручиваться вместе? Как то, как google keep woks? –

Смежные вопросы