Style showing error in android

末鹿安然 提交于 2019-12-13 06:38:45

问题


The following style shows error in eclipse

 <style name="AppTheme" parent="android:style/Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary</item>
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="colorControlNormal">@color/primary</item>
    <item name="colorControlActivated">@color/primary</item>
    <item name="colorControlHighlight">@color/primary</item>
</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@color/white</item>
</style>

it shows a error like this

error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Theme.AppCompat.Light.NoActionBar'.

while i searched, i get to know that it is the problem of the dependency. I tried a lot to solve it. But i still get the same error .

If i change the theme there is no error, but i need this particular style.

I tried the following theme

 <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">     
     // Your style here

this is woking . but i need the above theme .


回答1:


If your activity extends AppCompactActivity, your parent theme should be

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar" />

where as, if using ActionBarActivity, theme should be

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar" />

Make sure you have set up the dependencies in your project. This feature required appcompactv7.



来源:https://stackoverflow.com/questions/30979051/style-showing-error-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!