ActionBar Sherlock - Backgroundimage in Actionbar - android

I would love to set a Backgroundimage to the ActionBar which I imported with the "ActionBar Sherlock" library. However I can't find any link on the internet on how to distinctively set an BackgroundImage with XML.
Does anybody here have a hint which he could give me :)?

You create a style for your actionbar, it has to inherit Theme.Sherlock or Theme.Sherlock.Light.
Then link to your image in the attribute abBackground.
Assuming you have an image called myBackgroundImage in res/drawable your style xml would be:
<style name="Actionbar" parent="Theme.Sherlock">
<item name="abBackground">#drawable/myBackgroundImage</item>
</style>
You can find more attributes for the actionbar here: ActionBarSherlock - Theming
More on styles is found here: Styles and Themes | Android Developers

In your style.xml file add a custom style like this:
<style name="MyActionBarStyle" parent="Widget.Sherlock.ActionBar.TabBar">
<item name="android:background">#drawable/actionbar_tab_bg</item>
</style>
and add this style to your app theme with this to lines, the first for the Android <3.0 and the second for the >3.0
<style name="ReservasAppTheme" parent="#style/Theme.Sherlock.Light">
<item name="actionBarTabStyle">#style/MyActionBarStyle</item>
<item name="android:actionBarTabStyle">#style/MyActionBarStyle</item>
</style>
You should add this style to the application tag in manifest

you might want to look at : http://actionbarsherlock.com/theming.html

Related

in android studio i am using AppCompat api28 , how can i change toolbar attributes like background color and etc in style.xml file?

I have tried many options but whatever I use, it seems I cannot change the toolbar or action bar color & styles in the 'style.xml' file. it seems like using 'android.support.v7.widget.toolbar' is my only option . do you know a way so that I can change action bar styles in 'style.xml' file?
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#style/ThemeOverlay.AppCompat.ActionBar">
<item name="android:background">#ff0000</item>
</style>
and in the manifest i used 'CustomActionBarTheme' as my default theme .
i found the solution , my first mistake was that i should use a theme like :
'Theme.AppCompat.Light' , anything that starts with Theme , and finally creating an style like bellow , with parent set to 'Widget.AppCompat.ActionBar'
<style name="customActionbarStyle" parent="Widget.AppCompat.ActionBar">
<item name="background">#color/your_custom_color</item>
// also notice you must use color.xml file for colors and for some attributes
// like titleTextStyle , you must define another style and use it here like :
<item name="titleTextStyle">#style/your_title_text_style</item>
</style>
<style name="your_title_text_style">
<item name="android:textColor">#color/your_text_color</item>
</style>
you can find all other properties of ActionBar bellow :
https://developer.android.com/reference/android/R.styleable.html#ActionBar

Remove shadow between Actionbar and Tab

My app is using an own style which I made with the Android Action Bar Style Generator (Style compatibility = AppCombat). The color of the Actionbar and the tab are the same but the problem is that there is a shadow between them. How can I remove this shadow?
<style name="MyAppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowContentOverlay">#null</item>
"android:windowContentOverlay" is removing the shadow below the tab and not above.
Ok here's the solution by Audren Teissier which worked for me:
It's because you are using a drawable instead of a color.look for something like this:
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/yourcolor</item>
</style>
Replace the drawable by a color like above and it should go away.
Use the below property in your AppBarLayout
app:elevation="0dp"
Use the below code in your fragment
getSupportActionBar().setElevation(0);
The shadow on the status bar is system set and cannot be removed, however the status bar that you are referring to is inside of Theme.Holo.Light. To my knowledge it cannot be removed.
Hope I have understood your question correctly, that is you want to in a way merge the action bar with the tabs so there is no border in between -> the line or shadow you mentioned. If that is correct, then this is what you are looking for:
Add this to your MyAppTheme:
<item name="android:actionBarStyle">#style/LineRemover</item>
and change this line:
<item name="android:windowContentOverlay">#null</item>
to this:
<item name="android:windowActionBarOverlay">true</item>
and then add the following style below:
<style name="LineRemover" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#android:color/transparent</item>
</style>
In the end you have something like this:
<style name="MyAppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">#style/LineRemover</item>
</style>
<style name="LineRemover" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#android:color/transparent</item>
</style>
I guess you are aware that you have to register your theme in the android manifest (within your activity or application tags:
android:theme="#style/MyAppTheme" >
Please remember to mark this as your accepted answer if this helped you :)
if you set the tab layout elevation Remove.its working fine

dark action bar with Theme.AppCompat

I am using Theme.AppCompat for my app to get the dark look. Everything looks good, except the action bar using this theme looks ancient i.e. it has a bright blue bottom divider.
I want the action bar to look like it is in Theme.AppCompat.Light.DarkActionBar.
Looking at themes.xml, i find :
<style name="Theme.AppCompat.Light.DarkActionBar"
parent="Theme.Base.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">true</item>
</style>
<style name="Theme.Base.AppCompat.Light.DarkActionBar" parent="Theme.Base.AppCompat.Light">
<item name="actionBarDivider">#drawable/appcompat_divider_dark</item>
</style>
So i create my own style as below :
<style name="myTheme" parent="#style/Theme.AppCompat">
<item name="actionBarDivider">#drawable/appcompat_divider_dark</item>
</style>
But i get the build error :
No resource found that matches the given name (at 'actionBarDivider' with value
'#drawable/appcompat_divider_dark')
Why can't i use the same drawable that is being used by the framework?
The blue line is part of the background image used for the action bar. For example, you can find it in : sdk/platforms/android-19/data/res/drawable-xxhdpi/ab_transparent_dark_holo.9.png
The trick is to create your own Widget style by inheriting Widget.AppCompat.ActionBar and set the background attribute with your desired png, which does not have the blue line. I use the support library's existing#drawable/abc_ab_bottom_transparent_dark_holo. You can find it in the folder sdk/extras/android/support/v7/appcompat/res/drawable-hdpi/.
So create the below element in the styles.xml file.
<style name="myActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/abc_ab_bottom_transparent_dark_holo</item>
</style>
Then include this newly created style in your theme(already present in the styles.xml file) :
<style name="AppBaseTheme" parent="#style/Theme.AppCompat">
<item name="android:actionBarStyle">#style/myActionBar</item>
</style>
To enable this change in older APIs, make the same changes in all 3 folder - values-v14, values-v12 and values.
One important thing to note is that the "android:" namespace should not be used for the name attributes in the values-v12 and values folders.

Android custom theme

Hello I'm making a custom theme for my app. I want to have a custom ActionBar and background for the rest of the app (below the ActionBar). I'm wondering how to do the background. Right now I have:
<style name="MyTheme" parent="android:Theme.Holo">
<item name="android:actionBarStyle">#style/dActionBar</item>
</style>
<style name="dActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#4C721D</item>
<item name="android:textColor">#FFFFFF</item>
</style>
Would I just have to do <item name-"android:background"></item> in MyTheme or would I have to create another style? After I create this do I need to put it in the res/styles folder? Also what are the API restrictions on this, if any?
Don't forget to apply your theme to your application in your AndroidManifest.xml.
<application android:theme="#style/CustomActivityTheme" ... />
You can find all the information about styling the Actionbar here.
To style your ActionBar with a nice Holo-look, try this website
Hope this helps!
Try to use below code in your Style.xml file
<resources>
<style name="Theme.Sample" parent="Theme.AppCompat">
<item name="android:colorBackground">#color/primary_material_dark</item>
<item name="actionBarTheme">#color/colorGray</item>
</style>
</resources>
Just need to use android:colorBackground as a name of item to define the background color like as below:
<item name="android:colorBackground">#color/primary_material_dark</item>
Hope you get your answer,Thanks.

ActionBar tabs height

I want to change default ActionBar tab's height, but can't find any info about. Is there some style attribute or method to set height of tabs?
Thanks.
You have to change the height of the actionbar in order to change the height of the tabs.
theme.xml
<style name="YourTheme" parent="#android:style/Theme.Holo">
<item name="android:actionBarTabStyle">#style/tab_nav</item>
<item name="android:actionBarTabTextStyle">#style/tab_nav_text</item>
<item name="android:actionBarSize">80dp</item>
..
</style>
This is how you style the tabs. Although, I was having trouble actually getting the height to change. I'm not sure you can set a height via a Style to the TabView. You may have to create custom View and apply that to your tabs in your code. All the styles and attributes you need to reference are in the SDK. Look in the Values folder of the platform version you're working with. That's how I typically find out how to do this.
<style name="Widget.Holo.Tab" parent="#android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:height">#dp</item>
</style>
<style name="Your.Theme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarTabStyle">#style/Widget.Holo.Tab</item>
</style>
Be Aware that using
android:theme="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
instead of
android:theme="#android:style/Theme.Holo.Light.NoActionBar"
leads to the following problem: if you switch from [NoActionBar Activity] to [ActionBar Activity] ActionBar will JUMP

Categories

Resources