android - 用于编辑文本的评论部分(如 instagram)
问题描述
我正在尝试使评论部分与 Instagram 的编辑文本相同。我的要求是使用多行输入和扩展编辑文本将发送显示为 imeOptions。
这是我尝试过的,它开始在下一行输入,但编辑文本没有扩展。
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/etComment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:hint="Add comment here..."
android:imeOptions="actionSend"
android:inputType="textCapSentences"
android:lineSpacingExtra="2dp"
android:lineSpacingMultiplier="1.2"
android:maxHeight="@dimen/margin_100"
android:maxLength="200"
android:maxLines="10"
android:singleLine="false"
android:textColor="@color/white"
android:textColorHint="@color/hint_color"
android:textSize="14sp" />
解决方案
您的 XML 在附近是正确的。请同时添加 inputType = 'text'。
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/etComment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:hint="Add comment here..."
android:inputType="text|textCapSentences"
android:imeOptions="actionSend"
android:lineSpacingExtra="2dp"
android:lineSpacingMultiplier="1.2"
android:maxHeight="@dimen/margin_100"
android:maxLength="200"
android:singleLine="false"
android:textColor="@color/white"
android:textColorHint="@color/hint_color"
android:textSize="14sp" />
另外,在活动课上
etComment.setHorizontallyScrolling(false);
etComment.setMaxLines(Integer.MAX_VALUE);
让我知道,如果这有效。
推荐阅读
- java - 需要知道 VMS 日期到长的转换
- go - Gorilla mux 删除或替换现有路由
- antlr - 在保留错误消息的同时,如何在 python ANTLR 生成的解析器中出现第一个语法错误时失败?
- c# - 如何根据 ID 列表检查文档 ID?
- azure - 使用 oauth azure 数据工厂进行分页
- html - 是否可以在 HTML 中自动生成一些代码?
- c++ - C++,在 int 数组中输入字符串或字符输出 0 而不是 ascii 或错误
- amazon-web-services - AWS - 401 拒绝访问 - 详细信息正确,权限设置
- java - Spring Boot 微服务 - 使用 Jasper 进行报告应该是单独的服务吗?还是应该将 Jasper 集成到所有服务中?
- javascript - Django rest 框架:如何发送和下载 xlsx 文件?