Difference between style.xml and theme.xml android studio?

我与影子孤独终老i 提交于 2021-01-29 04:21:50

问题


Hey I'm trying to change the background of my action bar but I'm not quiet sure I understand the structure of the style files. So basically I have style.xml which is to pass on some elements a desired style. Then I've Theme.xml which is to have a group of styles in it, correct ? How do you link the two in other words how do I tell the theme I want the specified style in it ? I can't manage to change the background of the action bar so here is my code:

style.xml:

    <!-- Base application theme. -->
    <style name="MyActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:colorBackground">@color/color_lightBlue</item>
    </style>
</resources>

theme.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <style name="MyCustomTheme" parent="Theme.AppCompat.Light">

 </style>

</resources>

and wtf is v11/style ?


回答1:


Whether you put the attributes in styles.xml or theme.xml, they have the same effect finally if you apply the theme to your app or activity. In your AndroidManifest.xml, in order to let the theme have the effect you want, you should apply your customized theme like following to your app.

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >


来源:https://stackoverflow.com/questions/28444336/difference-between-style-xml-and-theme-xml-android-studio

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