Has the action bar icon size changed in Android 4.2 ? I've had a 120x48px HDPI icon that was rendered perfectly in Android 4.1 and below. It still is.
However, on any 4.2 device, it is squelched to fit as 48x48px from what I can see. Or something like that; it's definitely a square.
Any ideas ? Thanks !
So, I found an answer, it's kinda hacky but works (TM):
The general idea is to listen for the layout changes and apply new bounds to the drawables. This could look like this:
You then have to call updateActionBar in every Activity (I suggest making an abstract base activity from which you extend) in the following callbacks: onCreate onMenuOpened (I found that it would improve performance and reduce flickering (size changes of the drawables) if you call this delayed (e.g. 200ms)) onPrepareOptionsMenu (I found that it would improve performance and reduce flickering (size changes of the drawables) if you call this delayed (e.g. 200ms))
This works for me on Nexus 7 and Nexus 10 with Android 4.2. You can expect it to fail with future updates but at least for now it seems to work.
This is not ideal, but it appears you can get around this limitation by using an custom action view.
Something like this:
Where @layout/log_in_button points to a layout file containing an ImageButton with your icon set as the src.
You will have to bind the click listener in the OnCreateOptionsMenu method. There is a halfway good example here: http://developer.android.com/guide/topics/ui/actionbar.html#ActionView.
I only just learned to use this method, so I don't know yet if there are any major downfalls besides the increased complexity.