Get rid of blue line - android

With the help of ActionBarSherlock I try to get my app running on pre 3.0 devices. There is a blue divider in the action bar, which I want to have removed.
I figured out that it isn't a divider, but part of the background graphic of the action bar. To get rid of the blue line I decided to override the background like this:
<style name="MyActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#drawable/black</item>
<item name="background">#drawable/black</item>
</style>
I also set the background in the Java code:
getSupportActionBar().setStackedBackgroundDrawable(this.getResources().getDrawable(R.drawable.black));
As a result the blue line disappears on 4.x devices, but is still visible on 2.3.x devices. How do I get rid of the blue line on 2.3.x devices?

Stupid mistake: I used setStackedBackgroundDrawable instead of setBackgroundDrawable. It works fine with setBackgroundDrawable. This is the correct method to set the background of the action bar. setStackedBackgroundDrawable sets the background of the tab bar.

Seems that the blue line is part of the TabWidget you have there... But if it isn't you can have a look at this webpage: http://jgilfelt.github.io/android-actionbarstylegenerator/
It's a really good Action Bar style generator. Worth a try :)

actionBarDivider attribute belongs to the theme
Remove it like this:
<style name="AppTheme" parent="Theme.Sherlock">
<item name="android:actionBarDivider">#null</item>
</style>

Related

Navigation drawer toggle padding

I'm using appcompat v7 with the hamburger to arrow toggle.
However, I would like to add some padding on the left of the toggle.
This is my current situation :
http://nl.tinypic.com/r/2a0f712/8
This is what I would like to have :
http://nl.tinypic.com/r/v3q176/8
I've tried this :
findViewById(android.R.id.home).setPadding(25, 0, 15, 0);
But that didn't work. However, this did add padding on the right of the toggle.
I've also tried to add padding in the styles but that didn't work either.
AFAIK, the action is hard-coded in layout resources. U cant change the padding. Google did this to maintain the consistency across the app guess.
However u can define ur own icon in a drawable with ur own attributes (padding and all) and use it as an indicator by adding this line to styles.xml
<item name="android:homeAsUpIndicator">#drawable/xyz</item>
And the image u have shown about what u want is actually a toolbar and not an action bar. In toolbar, the icon is by default placed there.
To know more about toolbar and how to implement them, here is a link : http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html
I'm going to assume you are familiar with styling to some extent and recommend you go that route. FYI I have not confirmed the code below as working but I think it would be close to what you want.
For res/values-14/style.xml, something like this:
<!-- style for Action Bar -->
<style name="MyPaddedActionBar" parent="android:style/Widget.Holo.Light.ActionBarView">
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
And then for everything 14 and below, you would use AppCompat (res/values-14/style.xml):
<style name="MyPaddedActionBar" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>

ActionBar Light, but Holo Dark ActionMode CloseButton

I have a Theme.Holo.Light style, which is custom designed. Therefore I want to have the little tick on the contextual action mode in normal Theme.Holo style.
As you can see, it would look much better if the tick was white.
I thought the following would work, but no success.
<style name="PlayerTheme" parent="#android:style/Theme.Holo.Light">
...
<item name="android:actionModeCloseButtonStyle">#android:style/Widget.ActionButton.CloseMode</item>
</style>
Is there some way to make the tick white? Thanks!
You can copy the standard white check mark from the android icon pack into your project as a drawable. The icon pack can be found here: https://developer.android.com/design/downloads/index.html. It's under the 01_core_accept folder and named ic_action_accept.png.
Then, set the following property in your style file:
<item name="android:actionModeCloseDrawable">#drawable/ic_action_accept</item>
That should solve your problem.

Change background and text color of overflow items

I want to change the background and text colors of the pop up menu that appears when the user presses the overflow icon.
If I use Theme.Holo or Theme.Holo.Light it works, but I'm using Theme.Holo.Light.DarkActionBar and it never works. I'm starting to assume that it's an Android bug.
I'm testing on a Nexus 4 with 4.4.2 but it also doesn't work on an emulator with API 19.
After trying a lot of potential solutions that I came across here in StackOverflow, here is what I'm doing:
<style name="Theme.MyApp" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarWidgetTheme">#style/ActionBarWidget</item>
</style>
<style name="AndroidPitActionBarWidget" parent="android:Theme.Holo.Light">
<item name="android:popupMenuStyle">#android:style/Widget.Holo.Light.PopupMenu</item>
<item name="android:dropDownListViewStyle">#android:style/Widget.Holo.Light.ListView.DropDown</item>
</style>
That works but it changes the styling of the SearchView, which is another pain to change.
So I'm not considering this a solution.
What I want is to just change the background/text of the popup to the Light version, which is light background with black text.
I also tried setting those two attributes in the main theme instead of using the actionBarWidgetTheme.
It's really frustrating to waste hours on this kind of problems.
I also tried using Action Bar Style Generator to make the background white, but then the text is white and I can't change it to black.
Thanks very much in advance.
If you set the background color of that panel using the theme you get in the Action Bar Style Generator, you can try adding the android:textColor attribute of the drop down ListView.
If that does not work, you can alternately set the string color in code during your onCreateOptionsMenu method as detailed on this SO thread

Android Tab underline color not changing

So I've basically looked into every resource I saw online on how to change the blue underline in the tabs, but all of the advice has not worked in my case.
I tried actionbarsherlock, appcombat, holo from Action Bar Generator but all the coloring did was color the top action bar, not the tab underline. And yes the files did compile and did not have any errors, but for some reason, it seemed like the underline would never be changed even through the generator.
I am confused on how to change the default blue underline on the tabs, and I would SO EXTREMELY appreciate it if there was a working custom style xml that you would share.
After going to Changing ActionBar tabs underline color programmatically result is still same :/
Screen shot after trying from other page: http://i.stack.imgur.com/EOUbu.png
Anyone able to help me out?
I've been struggling with this for days, but finally found the solution. I'm using AppCompat. You can set colorAccent in your theme and that will change the highlight color on your ActionBar. Like so:
<item name="colorAccent">#color/highlightcolor</item>
Here it is in context:
<style name="LightTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/darkgrey</item>
<item name="colorPrimaryDark">#color/black</item>
<item name="colorAccent">#color/highlightcolor</item>
</style>
You need to define a custom theme for that, and then check the states to change the colour of the line. See if this answer helps you
Not sure if you are still pursuing this, but can you show what you did with Action Bar Generator? What Style entries did you add (in XML) and which drawables did you add?
I just went through the same process and it worked well with Action Bar Generator; just required a few lines added to the styles.xml, a new xml file in drawables folder, and then about 5 new image drawables into each of the resolution size folders (drawable-hdpi, etc).

styling ActionbarSherlock: textColor of the action-items

I was changing the background of the Actionbar in my App and to make text readable again I have to change the color of the text. I was successful with title/subtitle and the tab-texts, but I am struggling with the text of the action-items - they stay white no matter what I tried . Anyone has a hint on how to do that?
Also the overflow-icon is white which does not look too good on the wooden background - is that an extremely good reason to use the stuff below? I am not really sure what's the reason to not do it, but as I do not have a big device-test-park I better want to be sure ;-)
<!-- the following can be used to style the overflow menu button
only do this if you have an *extremely* good reason to!! -->
<!--<style name="MyOverflowButton" parent="Widget.Sherlock.ActionButton.Overflow">
<item name="android:src">#drawable/ic_menu_view</item>
<item name="android:background">#drawable/action_button_background</item>
</style>-->
I also struggled with this, but the solution to changing action item text color was:
<style name="My.Theme" parent="Theme.Sherlock.Light">
<item name="android:actionMenuTextColor">#android:color/white</item>
</style>
The key here was to use this attribute in the general theme, not in the actionbar style.
Try starting with android:theme="#style/Theme.Sherlock.Light" in your Manifest and then changing your styles. The light theme features dark action items. Or just look through the light theme to find out how to change them.

Categories

Resources