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的工作。