Reputation: 617
I tried several things before and searched the web, but no answer.
How do I get the current ActionBar
size?
I styled my ActionBar
like this:
<style name="MusicSlide.Theme.ActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:height">60dp</item>
<item name="android:actionBarSize">60dp</item>
<item name="android:homeAsUpIndicator">@drawable/ic_drawer</item>
<item name="android:background">@color/complete_transparent</item>
<item name="android:titleTextStyle">@style/MusicSlide.Theme.ActionBar.TitleText</item>
<item name="android:subtitleTextStyle">@style/MusicSlide.Theme.ActionBar.TitleText</item>
</style>
It is transparent.
In my app I implemented a DrawerLayout
. I don't want the DrawerLayout
to be underneath the ActionBar
, so I set the margin of the DrawerLayout
:
final TypedArray styledAttributes = mContext.getTheme().obtainStyledAttributes(
new int[] { android.R.attr.actionBarSize });
int actionheight = (int) styledAttributes.getDimension(0, 0);
styledAttributes.recycle();
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) mDrawerListRight
.getLayoutParams();
mlp.setMargins(0,(actionheight + statbarheight),0,0);
The problem is that android.R.attr.actionBarSize
returns the original height of the ActionBar
.
How do I get the 60dp
I set in my style?
Upvotes: 0
Views: 205
Reputation: 30804
android:actionBarSize
isn't an attribute of Widget.ActionBar
, this is why you aren't returning the correct value. Add that line to your app's theme, wherever you define android:actionBarStyle
.
Upvotes: 1