问题
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