登录按钮的颜色切换样式绑定失败?
warnning信息:
Hardcoded string "登 录", should use @string resource
代码应该没有问题:
activity_login.xml
styles_xml
<!-- 登录按钮--> <style name="commitBtn"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">@dimen/btnHeight</item> <item name="android:textColor">@android:color/white</item> <item name="android:textSize">@dimen/titleSize</item> <item name="android:layout_marginLeft">@dimen/marginSize</item> <item name="android:layout_marginRight">@dimen/marginSize</item> <item name="android:gravity">center</item> <item name="background">@drawable/btn_commit_select</item> </style>
btn_commit_select.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- View高亮 --> <item android:state_focused="true" android:drawable="@drawable/commit_btn_h"/> <item android:state_pressed="true" android:drawable="@drawable/commit_btn_h"/> <item android:state_selected="true" android:drawable="@drawable/commit_btn_h"/> <!-- View默认--> <item android:drawable="@drawable/commit_btn_n"/> </selector>
commit_btn_h.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!--实体颜色--> <solid android:color="@color/mainColorH"/> <!--弧度--> <corners android:radius="@dimen/radius"/> </shape>
commit_btn_n.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!--实体颜色--> <solid android:color="@color/mainColor"/> <!--弧度--> <corners android:radius="@dimen/radius"/> </shape>