我正在尝试将navigationIcon设置为使用Appcompat 21在工具栏中显示后退箭头。文件夹values-v21中的我的themes.xml如下所示:
<style name="AppTheme" parent="AppTheme.Base" />
<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:dropDownListViewStyle">@style/DropDownListViewStyle</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:navigationIcon">@drawable/abc_ic_ab_back_holo_light</item>
<item name="android:navigationContentDescription">@string/navigation_content_description</item>
我收到错误:
error: Error: No resource found that matches the given name
(at 'android:navigationIcon' with value '@drawable/abc_ic_ab_back_holo_light').
但是如果我在drawable上ctrl-B(goto声明)它显示它位于Appcompat库中。我是否需要将可绘制的Appcompat复制到我的本地R drawable文件夹中才能使用它,或者是否有某种方法让Android Studio能够理解它应该在编译时从那里获取它?
答案 0 :(得分:0)
这样做:
<style name="AppTheme" parent="AppTheme.Base" >
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:dropDownListViewStyle">@style/DropDownListViewStyle</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<!-- Add below line to style arrow -->
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<!-- Style arrow -->
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<!-- this will set your arrow color -->
<item name="color">@android:color/black</item>
<!-- You can customize other stuff too -->
<item name="spinBars">true</item>
<item name="thickness">3dp</item>
<item name="barSize">21dp</item>
<item name="drawableSize">48dp</item>
</style>
这样对我有用。希望这会有所帮助...