android – 如何使TextInputLayout中的错误消息出现在中心

android – 如何使TextInputLayout中的错误消息出现在中心,第1张

概述目前它看起来像附加此布局: <android.support.design.widget.TextInputLayout android:id="@+id/layoutCurrentPW" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_m 目前它看起来像附加此布局:
<androID.support.design.Widget.TextinputLayout    androID:ID="@+ID/layoutCurrentPW"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_margintop="10dp"    app:errorEnabled="true">

如何设置错误信息“密码必须至少为8个字符”到中心引力?
我尝试使用androID:gravity =“center”,但这不起作用.

编辑
包含EditText的布局:

<androID.support.design.Widget.TextinputLayout    androID:ID="@+ID/layoutCurrentPW"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_margintop="10dp"    app:errorEnabled="true">        <EditText            androID:ID="@+ID/editTextCurrentPassword"            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:layout_gravity="bottom"            androID:layout_marginleft="50dp"            androID:layout_marginRight="50dp"            androID:gravity="center"            androID:hint="@string/current_password"            androID:inputType="textPassword"            androID:textAppearance="?androID:attr/textAppearanceMedium"            androID:textcolor="@color/black" />    </androID.support.design.Widget.TextinputLayout>
解决方法 我想知道是否有任何方法可以从框架中处理它…似乎没有.

但TextinputLayout的工作方式是:
– 当用户触摸时,提示将显示在EditText的顶部.
– 错误消息将显示在TextinputLayout下面并对齐以启动.

由于提示和错误消息之间的不对齐,我的EditText有40dp的left_margin.所以现在,我从EditText中删除了left_margin 40dp并将其应用于TextinputLayout本身,所以它现在看起来很好.

获得的经验:-)是否必须将任何边距应用于EditText,如果可能的话,更好的相同,可以应用于TextinputLayout以保持正确放置提示和错误消息.

总结

以上是内存溢出为你收集整理的android – 如何使TextInputLayout中的错误消息出现在中心全部内容,希望文章能够帮你解决android – 如何使TextInputLayout中的错误消息出现在中心所遇到的程序开发问题。

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

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

原文地址: https://outofmemory.cn/web/1130535.html

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

发表评论

登录后才能评论

评论列表(0条)

保存