style.xml和theme.xml android studio之间的区别?

时间:2015-02-11 00:15:18

标签: android xml android-studio android-theme android-styles

嘿我试图改变操作栏的背景但是我不确定我是否理解了样式文件的结构。所以基本上我有style.xml,它将一些元素传递给所需的样式。那么我的Theme.xml里面有一组样式,对吗?如何将两者联系起来,换句话说,如何告诉主题我想要指定的样式呢?我无法改变操作栏的背景,所以这是我的代码:

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>

和wtf是v11 / style?

1 个答案:

答案 0 :(得分:3)

无论您将属性放在styles.xml还是theme.xml中,如果您将主题应用于您的应用或活动,它们最终会产生相同的效果。在AndroidManifest.xml中,为了让主题具有您想要的效果,您应该将自定义主题应用到您的应用中。

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