TextInputLayout error text padding

情到浓时终转凉″ 提交于 2019-12-07 04:00:42

问题


I am using TextInputLayout with AppCompatEditText having a custom xml shape based background for AppCompatEditText. Whenever i set some error , the error line starts from beginning of layout. Is there any way to give padding to that error line.


回答1:


You can reference error TextView by using:

TextView textView = (TextView) inputLayout.findViewById(android.support.design.R.id
            .textinput_error);

Then you can get its layout params to work with.




回答2:


<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
    android:id="@+id/tx_in_username"
    android:errorEnabled="true"
    android:layout_marginLeft="@dimen/margin_LEFT_RIGHT"
    android:layout_marginRight="@dimen/margin_LEFT_RIGHT"
android:layout_height="wrap_content">
<EditText
    android:layout_width="match_parent"
    android:layout_marginTop="10dp"
    android:layout_height="36sp"
    android:hint="Username"
    />



来源:https://stackoverflow.com/questions/34917677/textinputlayout-error-text-padding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!