我正在尝试获取用户评论,但在按下回车按钮后,由于换行,文本只是被隐藏了。我 我试图扩展我的 EditText View ,以便我可以显示至少 4 行评论。
<LinearLayout
android:id="@+id/comments_body_box"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="#fff"
android:elevation="8dp"
android:gravity="right"
android:maxHeight="150dp"
android:orientation="horizontal"
android:weightSum="10"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<EditText
android:id="@+id/comments_text_body"
android:layout_width="151dp"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_weight="8"
android:inputType="textCapSentences|textMultiLine"
android:maxHeight="100dp"
android:maxLength="2000"
android:maxLines="4"
android:paddingBottom="12dp"
android:paddingEnd="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="16dp" />
<ImageView
android:id="@+id/comment_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="12dp"
app:srcCompat="@drawable/ic_send_black_24dp" />
</LinearLayout>
以上是我当前的代码,有人能告诉我我的 XML 文件有什么问题吗?
我也添加了以下两个属性
android:maxLength="2000"
android:maxLines="4"
最佳答案
您需要将其添加到您的 EditText 属性中
android:lines="4"
此外,将高度设置为 wrap_content
android:layout_height="wrap_content"
关于java - EditText View 不在新行上扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51194387/