Reputation: 2839
I want to apply custom theme in android action bar title, but when I'm trying to do I got an error.
My Manifest:
<activity
android:name="com.lifegoal.eshop.Recharge_Activity"
android:theme="@style/MyTheme"
android:label="Mobile Recharge" >
my values v11 text
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
</style>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">@style/TitleBarTextColor</item>
<item name="android:background">@color/color_blue</item>
</style>
My Logcat out put
05-07 17:56:40.655: E/AndroidRuntime(1647): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lifegoal/com.lifegoal.eshop.Recharge_Activity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
05-07 17:56:40.655: E/AndroidRuntime(1647): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
if anyone know than help me...
<style name="TitleBarTextColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/color_white</item>
</style>
</resources>
Upvotes: 1
Views: 2586
Reputation: 4108
Follow the below link to design a custom theme
http://jgilfelt.github.io/android-actionbarstylegenerator/
After download the theme you just need to past the files into desired folder and inside AndroidManifesh.xml you need to write your custom theme name.
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/custom_theme_name" >
<activity
android:name=".MainActivity"
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>
Upvotes: 1
Reputation: 1238
As you probably use the AppBaseTheme for your application theme, you would also need a AppCompat theme for the overrriden activities:
Your MyTheme needs to have the parent Theme.AppCompat
or Theme.AppCompat.Light
, not the Holo theme as currenly.
Upvotes: 2