![](/img/trans.png)
[英]Android Textview with width 0 is forcing content to disappear below it
[英]Android TextView below EditText disappear
這是我的XML文件,其中定義了兩個EditText
組件和兩個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>
默認情況下,Android中的所有EditText小部件都是多行的。
這是一些示例代碼:
<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 -->
/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.