所以我无法访问库中的 appcompat 图标,我不知道为什么。
// build.gradle
`compile 'com.android.support:appcompat-v7:23.2.0'`
我正在尝试使用这个图标:@drawable/abc_ic_clear_mtrl_alpha
// styles.xml
<style name="MyTheme" parent="Theme.AppCompat.Light">
<item name="homeAsUpIndicator">@drawable/abc_ic_clear_mtrl_alpha</item>
</style>
但是我得到这个错误:Error:(12, 5) No resource found that matches the given name (at 'homeAsUpIndicator' with value '@drawable/abc_ic_clear_mtrl_alpha').
感谢任何帮助。
最佳答案
支持库 v7:23.2.0 现在支持 Vector Drawable。
这样一来,很多可绘制对象就变得无用或过时,并被移除。
我认为 abc_ic_clear_mtrl_alpha
被使用矢量的 abc_ic_clear_material
取代了:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:pathData="M19,6.41L17.59,5,12,10.59,6.41,5,5,6.41,10.59,12,5,17.59,6.41,19,12,13.41,17.59,19,19,17.59,13.41,12z"
android:fillColor="@android:color/white"/>
</vector>
如您所见,新图标使用了矢量和 colorControlNormal。
您可能需要查看 this question检查如何启用 Vector 并更改图标的颜色。
关于Android:我正在使用 AppCompatv7 库,但无法访问它的任何图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35735035/