大家都知道怎麼修改EditText下劃線顏色的方法
樓主在實際項目中遇到EditText 修改下劃線失效,找了很久沒找到問題
偶然的情況下,我發現我的項目是支持androidx的
android.enableJetifier=true
android.useAndroidX=true
那麼只需要把
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/MyEditText" />
改爲
<androidx.appcompat.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/MyEditText" />
就可以了
順便附上如何修改EditText下劃線顏色的方法:
在styles.xml裏面加上
<style name="MyEditText" parent="Theme.AppCompat.Light">
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/black</item>
</style>
在EditText標籤上加上
android:theme="@style/MyEditText"
就可以了