Android 应用自定义主题操作栏dosen';我没有出现
我有一个使用操作栏的应用程序 styles.xmlAndroid 应用自定义主题操作栏dosen';我没有出现,android,styles,android-actionbar,themes,Android,Styles,Android Actionbar,Themes,我有一个使用操作栏的应用程序 styles.xml <resources xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<color name="custom_theme_color">#ffa900</color>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">@color/custom_theme_color</item>
<item name="android:colorBackground">@color/custom_theme_color</item>
</style>
</resources>
#ffa900
@颜色/自定义主题颜色
@颜色/自定义主题颜色
显示
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.actionbar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CustomTheme" >
<activity
android:name="com.example.actionbar.ActionBarActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我的问题是,最初默认情况下,它使用的是主题。灯光和动作栏会显示,但当我使用父对象作为主题自定义主题时,灯光不起作用,但如果我使用父对象作为主题。Holo则可以用于自定义主题。有人知道吗 以下是我所做的。这对我来说非常有效。在Res->value->style中
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomTheme"
parent="@style/Theme.Light">
<item android:name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style android:name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item android:name="background">@drawable/actionbar_background</item>
</style>
</resources>
@样式/MyActionBar
@可绘制/操作栏\u背景
然后在drawable文件夹中(如果没有,请创建一个),创建一个新的xml actionbar_背景,并将下面的代码粘贴到其中
<?xml version="1.0" encoding="utf-8"?>
<bitmap android:tileMode="repeat"
android:src="@drawable/ab_texture_tile_example"
xmlns:android="http://schemas.android.com/apk/res/android"/>
然后将自定义颜色放置在其他可绘制文件夹中。这里的ab_纹理_标题_示例是我使用的背景色 使用下面的链接创建自定义背景色。