EditText实现自动换行,自动增高,上下滚动

EditText实现自动换行,自动增高,上下滚动

本文是做聊天室时,实现微信发信息的文本框即标题所述。
代码如下

<EditText
android:id="@+id/et_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:background="@drawable/et_input_shape"
android:gravity="center_vertical"
//多行文本
android:inputType="textMultiLine"
//显示4行
android:lines="4"
//最少1行,一开始是1行的高度
android:minLines="1"
android:padding="3dp"
android:textCursorDrawable="@null"
/>

主要代码是上面加注释的三行代码,应该都能看的懂
实现效果如下
这里写图片描述

猜你喜欢

转载自blog.csdn.net/song_liang_liang/article/details/79671518