tôi cố gắng để thực hiện một tùy chỉnh Drawable
bằng cách sử dụng thuộc tính nhưng tôi có một lỗi lạm phátSử dụng thuộc tính để thay đổi một yếu tố drawable màu
01-21 11:01:06.171: E/AndroidRuntime(13695): Caused by: android.content.res.Resources$NotFoundException:
File res/drawable/action_bar_background.xml from drawable resource ID #0x7f020000
action_bar_background.xml My
<?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="?attr/ActionBarEndColor"
android:startColor="?attr/ActionBarStartColor"
/>
</shape>
attr.xml My
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="ActionBarStartColor" format="reference|color" />
<attr name="ActionBarEndColor" format="reference|color" />
</resources>
Chủ đề của tôi.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Theme1" parent="@style/Theme.GreenDroid.Light.NoTitleBar">
<item name="ActionBarStartColor">@color/greyDark</item>
<item name="ActionBarEndColor">@color/greyLight</item>
</style>
<style name="Theme.Theme2" parent="@style/Theme.GreenDroid.Light.NoTitleBar">
<item name="ActionBarStartColor">@color/myRed</item>
<item name="ActionBarEndColor">@color/myWhite</item>
</style>
</resources>
Tôi không hiểu tại sao, thuộc tính của tôi là tham chiếu hoặc màu, nếu tôi "buộc" màu trong themes.xml, nó cũng không hoạt động.
Ai đó có thể trợ giúp?
Tôi đã tìm thấy this question nhưng không giải quyết được sự cố của tôi.
Giải pháp duy nhất Tôi đã tìm thấy, nó sử dụng nhiều tập tin drawable với màu choosen và làm cho các tài liệu tham khảo trong tập tin chủ đề. – Ahmet
Sự cố này đã được giải quyết trong bản xem trước Android L, như được chỉ định tại đây: https://code.google.com/p/android/issues/detail?id=26251 –
Tôi đã tìm thấy lỗi này trong Lollipop, nhưng vẫn không hoạt động với Kitkat và ít hơn –