Android:在TextInputLayout中的EditText右侧显示TextView

Android:在TextInputLayout中的EditText右侧显示TextView,第1张

概述我正在尝试创建一个如下图所示的布局 在上图中,密码字段位于TextInputLayout中,右侧还有一个TextView,指向忘记密码活动. 我使用相对布局,在没有TextInpt布局的情况下使用Textview实现EditText,如下所示 Code – xml file <EditText android:id="@+id/email_address" 我正在尝试创建一个如下图所示的布局

在上图中,密码字段位于TextinputLayout中,右侧还有一个TextVIEw,指向忘记密码活动.

我使用相对布局,在没有TextInpt布局的情况下使用TextvIEw实现EditText,如下所示

Code – xml file

<EditText            androID:ID="@+ID/email_address"            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:drawableleft="@drawable/ic_email"            androID:drawableStart="@drawable/ic_email"            androID:drawablepadding="10dp"            androID:hint="@string/email_address"            androID:textSize="14sp"            androID:maxlines="1"            androID:inputType="textEmailAddress" />        <relativeLayout            androID:layout_wIDth="fill_parent"            androID:layout_height="wrap_content"            androID:orIEntation="vertical">        <EditText            androID:ID="@+ID/etxt_password_login"            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:drawableleft="@drawable/ic_password"            androID:drawableStart="@drawable/ic_password"            androID:drawablepadding="10dp"            androID:textSize="14sp"            androID:hint="Password"            androID:layout_alignParentleft="true"            androID:inputType="textPassword"            androID:maxlines="1"/>            <TextVIEw                androID:ID="@+ID/txt_forget_password"                androID:layout_wIDth="wrap_content"                androID:layout_height="match_parent"                androID:layout_alignParentRight="true"                androID:layout_centerVertical="true"                androID:text="forget ?"                androID:textSize="12sp"                androID:layout_marginRight="10dp"                androID:textcolor="#808080"                />        </relativeLayout>

但是,如果我在EditText中添加TextinputLayout,我无法实现它..尝试并搜索了很多.

?我们如何解决上述问题

谢谢..

解决方法 尝试像这样 – 环绕相对或线性布局来获得这样的输出
<relativeLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content">        <androID.support.design.Widget.TextinputLayout            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content">            <EditText                androID:layout_wIDth="match_parent"                androID:layout_height="wrap_content"                androID:hint="Password"/>        </androID.support.design.Widget.TextinputLayout>        <TextVIEw            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_alignParentRight="true"            androID:layout_centerVertical="true"            androID:text="Forgot Password ?"/>    </relativeLayout>

注意:为编辑文本设置一些填充以进行对齐

总结

以上是内存溢出为你收集整理的Android:在TextInputLayout中的EditText右侧显示TextView全部内容,希望文章能够帮你解决Android:在TextInputLayout中的EditText右侧显示TextView所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1130821.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存