gpt4 book ai didi

android - maxLines 和 inputType ="textMultiLine"不工作

转载 作者:行者123 更新时间:2023-11-29 01:30:37 24 4
gpt4 key购买 nike

这是我的编辑文本:

<EditText
android:id="@+id/etMessage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:maxLines="4"
android:layout_weight="15" />

我希望它将输入行数扩展到最多 4 行(因此,maxLines="4")。但是,它仍然显示 1 行(实际上是 1 和第二行的四分之一是可见的)。

我尝试添加 android:lines="4""android:singleLine="false" 但无济于事。如何让它工作?

这是完整的 xml 文件:

<RelativeLayout
android:background="@color/colorBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">

<include
android:id="@+id/app_bar"
layout="@layout/app_bar" />

<RelativeLayout
android:layout_below="@+id/app_bar"
android:id="@+id/rlRest"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="7dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context=".MainActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/llInput">

<ListView
android:id="@+id/lvMessages"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>

<LinearLayout
android:id="@+id/llInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">

<EditText
android:id="@+id/etMessage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:maxLines="4"
android:layout_weight="15"/>

<ImageButton
android:id="@+id/bSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@mipmap/ic_send" />

</LinearLayout>

</RelativeLayout>
</RelativeLayout>

<fragment
android:id="@+id/fragmentUsers"
android:name="com.example.abc.OnlineNavDrawerFragment"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_online_nav_drawer"
tools:layout="@layout/fragment_online_nav_drawer" />

最佳答案

EditText 的高度设置为 match_parent

父级的高度设置为 wrap_content,约束子级为 ImageView,其高度为 wrap_content

因此,EditText 的高度受限于 ImageView 的高度。

在您的 EditText 中使用 wrap_content 的高度,以允许它扩展到完整大小。

关于android - maxLines 和 inputType ="textMultiLine"不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31404222/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com