Change line color in tabs - ActionBarSherlock - android

I'm using ActionBarSherlock to make my app compatible with older devices. The implementation was easy, but now i need to style the default Holo blue line that you see under the tabs to a red line.
I've been reading a few topics (topic 1, topic 2) here on SO and also the ABS doc (link), but i can't get it to work.
This is what i have so far.
In my AndroidManifest.xml i added this line to the application tag.
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" > <!-- SET THE DEFAULT THEME -->
Then in res/values/styles.xml i have:
<resources>
<style name="AppTheme" parent="android:Theme.Light" />
<style name="Theme.MyTheme" parent="Theme.Sherlock">
<item name="actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
</style>
<style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#ff000000</item>
<item name="background">#ff000000</item>
</style>
</resources>
But when i run my app, then i still see the default blue line color.
What am i doing wrong?
EDIT
Read this if you want to fully style your ActionBarSherlock!
I found an answer here on SO which gave the following link:
http://jgilfelt.github.com/android-actionbarstylegenerator
It's an easy generator which generates all the needed files for a fully customized ABS! All you have to do is copy the generated files into the appropiate folders and you're set!
Don't forget to enable the style (you'll have to enter a style name in the generator) in your AndroidManifest. For that, see the answer below.

A few things:
You don't really need <style name="AppTheme" parent="android:Theme.Light" /> anymore unless you want to change it to inherit Theme.Sherlock and use it for your app theme. If you decide to do this you will have to use Theme.MyTheme for activities.
Either way, to fix the problem you want to change
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
to
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.MyTheme" >
OR you can apply the theme directly to your activities:
<activity
android:name="com.awesome.package.activity.SomeActivity"
android:theme="#style/Theme.MyTheme"/>
Side note, I recommend this excellent actionbar theme generator

Set in your manifest file theme as follows:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.MyTheme" >
It will preserve all Sherlock themes and will add your custom styles.

Related

Account Kit advanced UI customizing

My default color is purple (#9b59b6) i want to change top title (blue) color to purple as well. I red manual on Customizing the Account Kit UI in Android Implemented style like this, but had no further luck changing top title color to purple.
//Delauft color: purple
UIManager uiManager = new SkinManager(SkinManager.Skin.CONTEMPORARY, ContextCompat.getColor(this, R.color.default_color), R.drawable.register_screen, SkinManager.Tint.WHITE, 0.1);
configurationBuilder.setUIManager(uiManager);
In my style.xml i have
<style name="AppBaseTheme" parent="android:style/Theme.Light.NoTitleBar">
<item name="colorPrimary">#9b59b6</item>
<item name="colorPrimaryDark">#9b59b6</item>
<item name="colorAccent">#9b59b6</item>
<!-- other elements-->
</style>
Other activities works fine.
I have app that look like this:
UPDATE
Solution: In AndroidManifest
<activity android:name="com.facebook.accountkit.ui.AccountKitActivity" android:theme="#style/CustomFbStyle" tools:replace="android:theme"/>
And in style.xml
<style name="CustomFbStyle" parent="Theme.AccountKit">
<item name="colorPrimary">#9b59b6</item>
<item name="colorPrimaryDark">#9b59b6</item>
</style>
Please check the theme you are using i.e Appbasetheme is the same which you have mentioned in application tag of manifest.
<application
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppbaseTheme">
or you can also use specific theme to specific class by giving android:theme tag to that class in manifest

Difference between style.xml and theme.xml android studio?

Hey I'm trying to change the background of my action bar but I'm not quiet sure I understand the structure of the style files. So basically I have style.xml which is to pass on some elements a desired style. Then I've Theme.xml which is to have a group of styles in it, correct ? How do you link the two in other words how do I tell the theme I want the specified style in it ? I can't manage to change the background of the action bar so here is my code:
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>
and wtf is v11/style ?
Whether you put the attributes in styles.xml or theme.xml, they have the same effect finally if you apply the theme to your app or activity. In your AndroidManifest.xml, in order to let the theme have the effect you want, you should apply your customized theme like following to your app.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >

Remove app title bar android

I know this question has been asked million times but whichever method I use is not good for me.
If I use
android:theme="#android:style/Theme.NoTitleBar"
in the manifest file, the whole theme of the app changes. If I put
requestWindowFeature(Window.FEATURE_NO_TITLE);
in the onCreate activities, it shows up shortly when starting an app.
Btw I don't have any theme selected, just using standard android.
It is unclear what you mean by "whole theme of app changes". For API Level 11+ devices, you probably should be using #android:style/Theme.Holo.NoActionBar.
If you add the theme to the application, it applies to the whole app.
android:theme="#android:style/Theme.NoTitleBar"
You have to add it to the activity declaration.
<activity
android:name=".YourActivity"
android:theme="#android:style/Theme.NoTitleBar"/>
To remove the title bar from your app in android studio
Open res > values > styles.xml file
Replace your code with:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Open your style.xml file, create a new style just like below.
You choose your own name and set the parent as below
<style name="your_own_name" parent="Theme.AppCompat.Light.NoActionBar">
</style>
In your AndroidManifest.xml file, set the theme name for the specific activity you dont want the bar to show and you are done
<activity android:theme ="#style/your_own_name" >
</activity>
This is what worked for me
android:theme="#style/Theme.AppCompat.NoActionBar">
when you create a new project in android then you will get default theme applied on your project, that has title bar. but if you want to remove or apply some other theme for your whole App then you can define like below at application level:
<application
android:name="com.mycomp.myproj.MainApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
but if you want to apply some theme only at some specific screens then you can define like below at activity level:
<activity
android:name="com.mycomp.myproj.MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme">
For android 8 and above support. Use this in your app theme file. I've modified my default in res/styles.xml :
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:background">#color/white</item>
</style>
Inside AndroidManifest
<activity
android:name=".activity.HomeMenu"
android:screenOrientation="nosensor"
android:theme="#android:style/Theme.Light.NoTitleBar">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and make sure your Class extends to Activity
If you have made a custom theme in styles.xml you can do this:
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Override the android colour scheme etc. -->
<item name="android:colorPrimary">#color/color_primary</item>
</style>
To remove the Action bar and title add to styles.xml:
<style name="AppTheme.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
Then in your AndroidManifest.xml you can use your custom theme with or without the action bar
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"> <---- With action bar
<activity
android:theme="#style/AppTheme.NoActionBar"> <---- No action bar
<intent-filter>
etc...

Can someone please help me understand why this code is not turning the Android Action Bar yellow?

I followed the Google's tutorial for changing the color of the Action Bar and wrote the code shown below, but the Action Bar still shows up as per the Holo Light theme.
styles.xml:
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light">
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<!-- Support library compatibility -->
<item name="background">#color/yellow</item>
</style>
Android Manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light" >
<activity
android:name="com.example.labside.MainActivity"
android:label="#string/app_name"
android:theme="#style/CustomActionBarTheme" >
The colors.xml has yellow defined as #FFFF00. Please let me know what I am doing wrong as this whole stuff about Action Bar styling with support for API level 8 is starting to get very confusing! As always, many thanks for all your help!! :)
What android version are you using? Take a look at this post: custom style action bar not working in android 4
Following this post, you need to declare your custom style twice. It looks like you are missing the declaration with the android: prefix.
So I guess, you'll have to add:
<item name="android:background">#color/yellow</item>

How to change the whole program’s skin style in Android?

How to change the whole program’s Skin style?
It can use the specialized apk to implement sharing. But I do not know how to directly use the apk element in the current program.
Could you give me some advice? Thanks!
you can define style for your app.
http://developer.android.com/guide/topics/ui/themes.html
You can define a style that has one of Android theme styles as parent:
<style name="main_style" parent="android:Theme.Black.NoTitleBar">
<item name="android:windowBackground">#drawable/background</item>
<item name="android:cacheColorHint">#00000000</item>
<!-- any other customizations -->
</style>
and then, in your AndroidManifest.xml, apply it the following way
to the activity:
<activity
android:name=".Activity1"
android:theme="#style/main_style"/>
<activity
android:name=".Activity2"
android:theme="#style/main_style"/>
or to your whole application:
<application
android:theme="#style/main_style">
There's no need to define your own theme, you can also use one of stock Android themes:
<application
android:theme="#android:style/Theme.Black.NoTitleBar">

Categories

Resources