嘿,我正在尝试更改操作栏的背景,但我不确定我是否理解样式文件的结构。因此,基本上我有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/样式?
无论您将属性放在styles.xml
还是theme.xml
中,如果您将主题应用于应用程序或活动,它们最终都具有相同的效果。在你的AndroidManifest.xml
中,为了让主题具有你想要的效果,你应该将你定制的主题应用到你的应用程序中,比如下面。
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >