在Android中EditText的末尾显示不可编辑的文本 [英] Display non-editable text at end of EditText in android

查看:171
本文介绍了在Android中EditText的末尾显示不可编辑的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要在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 an EditText inside another LinearLayout 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 to wrap_content and give it a weight of 0. For your EditText, set its width to 0dp and its weight to 1. It should now fill all remaining space. Set the background to @null for both.

      这篇关于在Android中EditText的末尾显示不可编辑的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆