简体   繁体   English

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

[英]Difference between style.xml and theme.xml android studio?

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. 所以基本上我有style.xml,它将一些元素传递给所需的样式。 Then I've Theme.xml which is to have a group of styles in it, correct ? 那么我的Theme.xml里面有一组样式,对吗? 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: 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: theme.xml:

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

 </style>

</resources>

and wtf is v11/style ? 和wtf是v11 /风格?

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM