Skip to content Skip to sidebar Skip to footer

Why Have Android:actionlayout And Android:icon At The Same Time?

I am reading about action bars in BusyCoder's Android guide. There is an example: actionLayout, but there is enough room for an action item, which would therefore show the icon. Also, with ActionBarSherlock, the icon is shown even in the overflow on Android 2.x devices, and so again if the actionLayout would be too large, the icon might get used. Also, if I used ifRoom|collapseActionView instead of just ifRoom, the icon would be used.

That being said:

  • My sample does not actually watch for this theoretical action item, should it appear, to do anything if the user clicks on it

  • I am guessing at possible action bar behavior, as I have not tried any experiments to force the action bar to decide whether there is enough room for all actionLayout-configured items

Solution 2:

here android:icon is defined to supply an icon for your menu item. This is always optional but it is recommended to have an icon for the menu item.

android:actionLayout is defined to supply a custom view for the menu item again this is optional but if u need some Image Views, Text Views, Edit Text Views etc. in your menu item, this is the way to go.

If you need more help see these guides. These I think will be more helpful to you.

Action Bar Android Developer Guide

Menu Resource Android Developer Guide

Also take a look at this example. This may give you a much better idea about android Action bars.

vimaltuts.com/android-tutorial-for-beginners/android-action-bar-tab-menu-example

                        Thank You!

Post a Comment for "Why Have Android:actionlayout And Android:icon At The Same Time?"