在Android中EditText的末尾显示不可编辑的文本 [英] Display non-editable text at end of EditText in android
问题描述
我想要在EditText的末尾显示文本,如上图所示的URLName.如何实现?无法编辑文本.我正在设计库的TextInputLayout
内部使用此editText.预先感谢
I want to display text at the end of EditText as shown in the image above for URLName.How could I acheive this ?The text cannot be edited.I am using this editText inside TextInputLayout
from the design library. thanks in advance
推荐答案
-
创建一个
LinearLayout
.在此布局内一行的示例可能是标题(即URL名称)或文本输入字段.Create a
LinearLayout
. An example of a row inside this layout would be a title (i.e. URL name) or a text entry field.将当前行的
LinearLayout
的背景设置为自定义可绘制对象,以创建一条细红线.遵循此帖子中的答案以获取想法.Set the background of the
LinearLayout
for the current row to a custom drawable to create a thin red line. Follow the answers on this post for ideas.对于问题中提到的URL输入字段,请在当前行内的另一个
LinearLayout
中创建一个TextView
和一个EditText
.For the URL entry field mentioned in your question, create a
TextView
and anEditText
inside anotherLinearLayout
inside the current row.TextView
将包含".sitename.com".将其设置为wrap_content
并为其指定0
.对于您的EditText
,将其width
设置为0dp
,将其weight
设置为1
.现在,它将填充所有剩余空间.将两者的background
设置为@null
.The
TextView
will contain ".sitename.com". Set it towrap_content
and give it aweight
of0
. For yourEditText
, set itswidth
to0dp
and itsweight
to1
. It should now fill all remaining space. Set thebackground
to@null
for both.这篇关于在Android中EditText的末尾显示不可编辑的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!