Holo theme in android makes application stop 'unfortunately' - android

so I'm trying to style my application, and I've run into problems when using the Holo theme. I have no intrest in earlier versions of android, so I'don't want to use AppCompat.
To do my error checking I have created an empty app with one blank activity. This is my styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/AppTheme_ActionBarTheme</item>
</style>
<style name="AppTheme_ActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/light_green</item>
<item name="android:titleTextStyle">#style/AppTheme_ActionBarTheme_Text</item>
</style>
<style name="AppTheme_ActionBarTheme_Text" parent="AppTheme_ActionBarTheme">
<item name="android:textColor">#color/light</item>
</style>
</resources>
and this is my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fokamb.chmielowskim.fokamb" >
<uses-sdk android:targetSdkVersion="15" android:minSdkVersion="14"/>
<application
android:allowBackup="true"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="#string/main_act_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I didn't change any other files, and I tried running this app on an emulator with API level 21 and my phone with api 19. On both, i get the message "Unfortunately, FokaMB has stopped"
Even though, in the preview window in android studio the app looks the way I would've liked it to.
So, where might be my mistake? If I use AppCompat app works fine, but im unable to change the text color of actionbar (even though the background changes). Any help would be greatly appreciated:)

Related

Change background color of actionBar [duplicate]

I've a newly created project and the first thing I want to do is add and style an action bar. I made it the way they tell in their official tutorials and even tried some other ways but I just can't make it work.
After many tries, I decided to do something really basic but even like that I can't make it work.
This is what I have:
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
</style>
<style name="ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/blue</item>
</style>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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>
Another question is what is the difference between the #android:style/Theme.Holo, #style/Theme.AppCompat.Light.DarkActionBar or simply Theme.AppCompat.Light.DarkActionBar?
Thanks.
Per the Using the Material Theme training, the Material theme (and AppCompat theme's which backport / use Material theming) use colorPrimary to color the action bar. Therefore your theme can be:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/blue</item>
</style>
You'll find more details on how to theme using AppCompat / Material in the AppCompat v21 blog post and in this pro-tip
I recommend you use this tools to generate ActionBar styles:
http://jgilfelt.github.io/android-actionbarstylegenerator/
Good Luck!

Unable to give style to action bar in android studio 1.0.1

I am trying to give colour/image as background to the action bar in android studio (), max sdk ver 21, but with no success. What is wrong with the below code and or else how to do it:
<resources>
<style name="CustomActionBarTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="android:background">#drawable/back</item>
</style>
</resources>
If you are facing problem in android lollipop actionbar, then first of all you have to different style.xml file in your res folder named as values-v21.
in this create style.xml as in values folder.
you did not added parent theme correctly. you should create style1 whose parent is style2. In style2 parent add desired theme like parent="#android:style/ThemeOverlay.Material.Light".
In menifest add style1 as your application theme.
Take a look on example.
Here colorPrimary for your action bar,
colorPrimaryDark for your notification bar outside application,
colorAccent for native dialogs like progressbar, tabs etc.
<resources>
<style name="AppBaseTheme" parent="#android:style/ThemeOverlay.Material.Light">
<item name="android:colorPrimary">#color/material_blue_500</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">#color/material_blue_700</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">#color/material_green_A200</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
your xml file should be like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="info.androidhive.slidingmenu"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="info.androidhive.slidingmenu.MainActivity"
android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
If you haven't already, remember to reference your theme in AndroidManifest.xml:
android:theme="#style/CustomActionBarTheme"
Also, make sure that in your Java code, you activity extends ActionBarActivity instead of just Activity as you are using the AppCompat Support Library.
If none of this works, go to your build.gradle and check that in the dependencies section, you have:
compile 'com.android.support:appcompat-v7:21.0.3'

Generated style not being applied on Android application

I've used the following style:
http://jgilfelt.github.io/android-actionbarstylegenerator/#name=zhc_style&compat=appcompat&theme=light_dark&actionbarstyle=solid&texture=1&hairline=1&neutralPressed=1&backColor=cd0079%2C100&secondaryColor=cd0079%2C100&tabColor=cd0079%2C100&tertiaryColor=303030%2C100&accentColor=cd0079%2C100&cabBackColor=002E3E%2C100&cabHighlightColor=cd0079%2C100
Long story short, it makes the ActionBar purple.
I've taken all the files from the .zip file and placed them in my project. Within the <resources> of the file styles_zhc_style.xml I've got:
<style name="Theme.Zhc_style" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_zhc_style</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Zhc_style</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Zhc_style</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Zhc_style</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Zhc_style</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Zhc_style</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_zhc_style</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_zhc_style</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Zhc_style</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">#style/Theme.Zhc_style.Widget</item>
</style>
I've changed my Android Manifest to the following:
<application
android:allowBackup="true"
android:name="com.zhc.android.ZHCApp"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Zhc_style" >
<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>
My minimum sdk version is 16, my target sdk version is 21.
I still get the dark ActionBar on top of my application. When I change the settings using the Style Generator to have the Base Theme 'Light' and move all the files again, I see that the ActionBar indeed becomes light themed. Lighter ActionBar, black instead of white letters... but still no purple.
What am I doing wrong?
I've 'solved' the problem by removing the NavigationDrawer Fragment I've used, and placed a Toolbar on top instead. (Android 5.0).
Not really a solution, but an alternative people could consider.

App is not using custom theme

i want to disable the ActionBar in my application, I have been looking for a solution on stackoverflow for quiet a while but nothing helped. My problem is that my custom-theme "NoActionBar" is not used, instead it keeps using "AppBaseTheme" although I changed it in the manifest:
android:theme="#style/NoActionBar"
values-v14 styles:
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="NoActionBar" parent="AppBaseTheme">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
same with values-v11. In values i added this line but I think its not neccessary:
<style name="NoActionBar" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
</style>
I tried to change the parent of NoActionBar, didn't work. I tried to create an extra .xml for "NoActionBar" but that didn't work either because the manifest didn't find it. I tried other tipps from stackoverflow questions but they're pretty outdated.
I know when i put the two "items" within the "AppBaseTheme"-style it works, but I'm pretty sure that is not the proper way to use it?
In a nutshell:
Can somebody please explain to me why its not using my theme? What theme needs which parent? (How would I define multiple themes?)
I hope I explained it properly, I assume the answer is rather simple, sorry in advance for my language mistakes, I'm not native. Thanks!
Edit Manifest:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/NoActionBar" >
<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>
You are using your theme but your parent can't be AppBaseTheme, you have to use as parent for example Theme.Holo.NoActionBar or at least a style without action bar.

ViewPageIndicator- Jake Wharton- Why tabs with viewpager shows title unlike ICS?

I am attaching image to explain my question in more detail.
Also attaching android manifest.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="XXXXXXXXXX"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:targetSdkVersion="15" android:minSdkVersion="8"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:hardwareAccelerated="true">
<activity
android:label="#string/app_name"
android:name="TabsMainActivity"
<!-- If I remove the line below I get normal
ICS action bar instead of title bar u see in below image -->
android:theme="#style/Theme.PageIndicatorDefaults">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Also if you see the edit text and spinner UI , its like one that we see on android versions below ICS.
And Screenshot is from my phone running ICS 4.0.4.
I solved the problem by editing vpi__styles.xml from ViewPagerIndicator.
The code before I edited was : -
<style name="Theme.PageIndicatorDefaults" parent="android.Theme">
<item name="vpiCirclePageIndicatorStyle">#style/Widget.CirclePageIndicator</item>
<item name="vpiTitlePageIndicatorStyle">#style/Widget.TitlePageIndicator</item>
<item name="vpiTabPageIndicatorStyle">#style/Widget.TabPageIndicator</item>
<item name="vpiTabTextStyle">#style/Widget.TabPageIndicator.Text</item>
</style>
The code after I edited file is :-
<style name="Theme"></style> <!-- I declared new style which dont have parent with android.Theme -->
<style name="Theme.PageIndicatorDefaults" parent="Theme"> <!-- Extended this style from style I declared above -->
<item name="vpiCirclePageIndicatorStyle">#style/Widget.CirclePageIndicator</item>
<item name="vpiTitlePageIndicatorStyle">#style/Widget.TitlePageIndicator</item>
<item name="vpiTabPageIndicatorStyle">#style/Widget.TabPageIndicator</item>
<item name="vpiTabTextStyle">#style/Widget.TabPageIndicator.Text</item>
</style>
This solved the problem and shows action bar instead of title bar on android 4 devices and normal title bar on android 2.1- 2.3.x devices.

Categories

Resources