Change size of Action Bar Icons/ Action Buttons

Updated 17 August 2017

Save

Changing Action Bar Icons dimension is a very hard task until you find out how?

Well while working on changing the gap between the Action Bar icons I have used, I figure out that actually, we can only set icons for this purpose and not kind of manipulate their dimensions via XML or Java coding of the view.

And if we do it  simply by changing the dimensions of an item then that is wrong because that just changed the size of icon with respect to the view in which it is to be loaded and not the dimensions of the view itself,
the result would be smaller images with the bigger gap between them.

Well there are two solutions to this problem :

  1. Manipulating the resources of your app by using the drawable of a lower resolution in an upper resolution: E.g copy the drawable icon from mdpi folder and paste it to hdpi folder of your app.
    and continue for all the folders generated.
    P.S.: I personally don’t recommend this, but it is quite fast and causes less effort.
  2. Creating a theme for yourself and use it in your XML’s toolbars theme .
    For this, first you need to create a theme for your toolbar by coding something like this:-

    then simply change the theme of your Toolbar, by adding this line inside your Toolbar Tag in your respective XML file.

    In Case you are wondering the difference between  Theme and PopupTheme, please refer here

    For the snippet under the styles tags, the attributes used are very simple:
    -> colorControlNormal : to change the color .
    -> actionButtonStyle & android:actionButtonStyle : it is just to change the styles of the buttons of the action bar, the only difference between them that I can acknowledge now, is that second one is not supported in previous versions of android.

    And it is done !! : )
    P.S: You can always change the dimensions as per your need.
    Keep coding and Keep Sharing : )
    References: http://stackoverflow.com/questions/15299508/i-want-to-change-actionbar-icon-size

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home