[英]After applying custom theme Action bar dosen't show up
I have an application using action bar 我有一个使用操作栏的应用程序
styles.xml 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.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>
manifest 表现
<?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>
My Question is that initially by default it was using Theme.Light and action bar is displayed but when I have customized a theme using parent as Theme.Light it dosen't work but if I use parent as Theme.Holo then it works for custom theme. 我的问题是,默认情况下最初使用的是Theme.Light和操作栏,但是当我使用父级作为Theme.Light自定义主题时,它不起作用,但是如果我将parent用作Theme.Holo,则它适用于自定义主题。 Anyone any Idea. 任何人任何想法。
Here is what I have done. 这是我所做的。 It is working perfectly for me. 它对我来说非常有效。 In Res->value->style 在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>
Then in drawable folder(create one if you don't have it),create a new xml actionbar_background and paste the below code in it. 然后在drawable文件夹中(如果没有则创建一个),创建一个新的xml actionbar_background并将以下代码粘贴到其中。
<?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"/>
Then you place your custom colour in the other drawable folders. 然后,将自定义颜色放置在其他可绘制文件夹中。 Here ab_texture_title_example is my background colour used. 这里ab_texture_title_example是我使用的背景色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.