Tôi có kiểu nút với nền màu xanh hoạt động tốt trong API 22, nhưng nút tương tự xuất hiện với màu xám đậm mà không có kiểu được áp dụng trong Android 4. Đây là kiểu của tôi:Kiểu nút hoạt động trong Android 5 nhưng không phải là Android 4
<style name="MyApp.Plain" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background</item>
<item name="android:buttonStyle">@style/MyApp.Widget.Button</item>
</style>
<style name="MyApp.Widget.Button" parent="@android:style/Widget.Button">
<item name="android:background">@drawable/btn_blue</item>
<item name="android:focusable">true</item>
<item name="android:clickable">true</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">#fff</item>
<item name="android:gravity">center_vertical|center_horizontal</item>
</style>
btn_blue.xml My
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_disabled" android:state_enabled="false"/>
<item android:drawable="@drawable/btn_pressed" android:state_enabled="true" android:state_pressed="true"/>
<item android:drawable="@drawable/btn_normal_blue" android:state_enabled="true"/>
</selector>
và btn_normal_blue.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="#368ac6"
android:startColor="#0e58a4" />
<corners android:radius="20dp" />
</shape>
Điều gì có thể lý do cho hành vi này và làm thế nào tôi có thể sửa lỗi này?
CHỈNH SỬA: Tính năng này không hoạt động với hỗ trợ v7: 22.2.0, nhưng hoạt động với v7: 21.0.3. Tôi đã không thay đổi bất cứ điều gì ngoài sự phụ thuộc và thay đổi AppCompatActivity thành ActionBarActivity.
Có thể đây là lỗi Android.
hiển thị drawable/btn_blue nội dung –
Có cơ hội bạn có các thư mục riêng biệt cho các phiên bản API, và phong cách này chỉ là một trong số chúng? – AdamMc331
@ mcAdam331: Không, tôi chỉ có một tệp kiểu. – barq