KDeogharkar KDeogharkar - 1 year ago 153
Android Question

Get the Height of ActionBar

I am using Actionbar in my application.
I want the Height of the ActionBar Programatically hence I am using :


But I am getting 0 value of Height.
So How can I get the Height of ActionBar?

Answer Source

I found the alternative of ActionBar.getHeight()
If anyone facing the same issue then this link is useful.

While @birdy's answer is an option if you want to explicitly control the ActionBar size there is a way to pull it up without locking the size that I found in support documentation. It's a little awkward but it's worked for me. You'll need a context, this example would be valid in an Activity.

// Calculate ActionBar's height 
TypedValue tv = new TypedValue(); 
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
    actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics()); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download