ActionBarsherlock how to set dividers on menu items with icons only - android

Hello android developers,
I know this question have been asked many of times, and I have also tried many solutions but they are not working for me.
Firstly I am using action bar sherlock library to show action bar,and I want to show dividers between menu items with icons only.
For that I create custom style for showing divider but they are not showing.
<style name="Theme.SherlockCustom" parent="#style/Theme.Sherlock.Light">
<item name="android:actionBarDivider">#drawable/actionbar_seprator</item>
<item name="android:showDividers">middle</item>
</style>
And also tried to update sherlock library ActionMenuItemView.java for ActionBar where needsDividerBefore() will always give true. But this patch also not worked for me. Please help where I am going wrong. Thanks.

You can't get dividers on versions > 4.0 for your scenario unless you use a custom view for your action bar; the native implementation controls the behavior internally and doesn't give any hook to modify that.
HTH,
Ali.

Related

Android: Tabbed Layout or Android Tabs without having an Action Bar?

So I created my app to have tabs on the action bar which direct to three fragment windows. I decided to change the theme of the app to "#android:style/Theme.Holo.Light.NoActionBar.Fullscreen" and suddenely my app started crashing with a nullpointer exception. After sometime I realized that the theme change, which disabled the action bar might have caused this.
Is there a way to implement tabbed layout without an action bar? A custom action bar? I badly want to use that theme. OR is there a way to customize the action bar: change the color or add custom icons and search function to make it more visually appealing?
Thank you!
Is there a way to implement tabbed layout without an action bar?
Use ViewPager and any one of several tabbed indicators, such as PagerTabStrip, the TabPageIndicator from the ViewPagerIndicator library, PagerSlidingTabStrip, etc.
Or, use FragmentTabHost.
is there a way to customize the action bar: change the color or add custom icons and search function to make it more visually appealing?
You are responsible for your own icons, so if you do not like your icons, talk to yourself about having yourself come up with better ones.
You can change the color of the action bar via a custom theme, such as one you might set up with Jeff Gilfelt's Action Bar Style Generator. Or, switch to using the appcompat-v7 edition of the action bar (with ActionBarActivity) and you can use a simpler custom theme where you just set some tint values.
as you have not provided code here i think you are using API 21 or less.. so you should change theme of your android application.
change styles.xml file as follows
<resources>
<!-- Base application theme. -->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>

Actionbar menu item background on select

I am using sherlock actionbar and made custom action bar using differnt color (blue) . When there are menu items . as i click on menu item . items background turns in to gray . Not able to point which attribute of the style is making this effect had checked the most possibility . any help would be appreciated
after some analysis found following answer
<item name="selectableItemBackground">#null</item>
<item name="android:selectableItemBackground">#null</item>
<item name="actionBarItemBackground">#null</item>
<item name="android:actionBarItemBackground">#null</item>
The issue is you need to override these attributes in your application. donot try changing in actionbar apk libary. that was the point i missed while fixing this.

ActionBarSherlock with Action Bar Style Generator

for the last few days I'm trying to implement custom theme, which is created by Action Bar Style Generator to my application. I'm able to use theme with some generic samples from SDK, but I'm not able to use it with my application which uses ActionBarSherlock.
My application with ActionBarSherlock is a modified sample of Tabs and Pager.
Steps which I do:
Create theme with Android Action Bar Style Generator.
Copy theme to res folder inside my application.
Change theme in Manifest file.
After those steps only 'Action bar color' changes to correct one. All other styles are not used in application. I have tried many different approaches which I found online, but without success.
Thank you very much for your help.
Did you add the proper items to your App's theme in styles.xml? You need to use attributes that are NOT prefixed with android:, for example:
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="background">#drawable/bg_striped</item>
<item name="backgroundSplit">#drawable/bg_striped_split</item>
You would also keep the properly prefixed ones for Android versions that have native actionbar.
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:background">#drawable/bg_striped</item>
<item name="android:backgroundSplit">#drawable/bg_striped_split</item>
The best place to understand this is to look at the demo provided with the ActionBarSherlock library project.
I managed to fix the problem.
I missed android:background attribute in TabWidget. This partially
solves the problem.
I had to set setLeftStripDrawable and setRightStripDrawable programatically.

Custom Title bar with Holo Themes

Like a lot of people, I would like to use a custom title bar in android but also use the Holo theme. I've seen a lot of posts recommending using Theme.Holo.NoActionBar but it still gives me the same error as when I change my custom theme to use Theme.Holo. I want to resolve once and for all, is it possible to use a custom title bar like this:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title_bar);
which seems to be the most common way to do it.
Well you can create another element layout which looks like title bar for you and in the current activity you can set requestWindowFeature(Window.FEATURE_NO_TITLE)
This way you get the holo theme aswell as custom title. This is commonly used practice in this scenario.
you can define parent="#android:style/Theme.Holo"
then just disable the windows action bar
like this
<item name="android:windowActionBar">false</item>
in theme.
It's working for me...

ActionBarSherlock overflow listview

After integrating the ActionBarSherlock in my android app I noticed that the dropdown menu that drops when the user hits the overflow button differs between 2.* and 4.*.
I have successfully customize this dropdown menu for 2.* with the right colours, but the dropdown menu in 4.* is displayed with white color andblack text and nothing that I do seems to modify this menu.
Do I need to do anything special to customize this dropdown menu in 4.*? it is even possible?
Thanks
When you add a style for ABS, you must be sure to also include the proper Android tags. E.g.
Not just
<item name="actionBarStyle">#style/ActionBar</item>
But
<item name="actionBarStyle">#style/ActionBar</item>
<item name="android:actionBarStyle">#style/ActionBar</item>
The former only controls ABS, and the library uses the standard Action Bar on 4.x.

Categories

Resources