AppCompatEditText設置下劃線顏色的知識。
如下圖所示:
style中添加
</pre><pre name="code" class="html"> <style name="txt_lab" parent="TextAppearance.AppCompat">
<!-- 默認狀態提示顏色和字體-->
<item name="android:textColorHint">#8c8c8c</item>
<item name="android:textSize">14sp</item>
<!-- 下面可以根據需要設置,如果沒有將默認使用默認theme的顏色 -->
<!-- Label標籤的顏色 -->
<item name="colorAccent">#c6174e</item>
<!-- 默認狀態狀態設置底線顏色 -->
<item name="colorControlNormal">#3F51b5</item>
<!-- 選擇的底線顏色 -->
<item name="colorControlActivated">#c6174e</item>
</style>
然後直接使用就可以了。
還可以添加錯誤提示。
<android.support.design.widget.TextInputLayout
android:id="@+id/til_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/txt_lab"
app:errorEnabled="true"
app:errorTextAppearance="@style/txt_lab_msg"
>
<android.support.v7.widget.AppCompatEditText
android:id="@+id/acet_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/txt_password"
/>
</android.support.design.widget.TextInputLayout>
<style name="txt_lab_msg" parent="@android:style/TextAppearance">
<item name="android:textColor">#c6174e</item>
<item name="android:textSize">12sp</item>
</style>
這樣,輸入錯誤時就有提示信息。
android AppCompatEditText 自定義下劃線顏色 就講完了。
就這麼簡單。