4

我使用TextInputLayout有对AppCompatEditText自定义XML的基于形状的背景AppCompatEditText。每当我设置一些错误,错误行从布局开始。有没有什么办法给这个错误线填充。TextInputLayout错误文本填充

enter image description here

+0

参考http://stackoverflow.com/questions/32609710/textinputlayout-how-to-give-padding-or-margin-to-hint – sasikumar

+0

你能用你试过的代码更新这个问题吗? – Kae10

+0

使用'setError(null)' –

回答

0
<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" 
    /> 

+0

不要使用marginLeft和marginRight – Mallikarjuna

2

您可以通过使用引用错误的TextView:

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

然后你就可以得到它的布局PARAMS的工作。