2016-03-01 34 views
3

所以我無法訪問庫中的appcompat圖標,我不知道爲什麼。Android:我正在使用AppCompatv7庫,但無法訪問它的任何圖標?

// 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').

任何幫助表示讚賞感謝。

回答

3

支持庫v7:23.2.0現在支持Vector Drawable。

這樣,很多繪圖變得無用或過時,並刪除。

我認爲abc_ic_clear_mtrl_alphaabc_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並更改圖標的顏色。

0

對於最新的版本,你可以發現abc_ic_clear_mtrl_alpha和很多其他的圖標這樣做:

android.support.v7.appcompat.R.drawable.abc_ic_clear_material

相關問題