Android actionbarsherlock 获取高度 return 0
Android actionbarsherlock get height return 0
我正在寻找获取我的操作栏 (sherlock) 的高度。返回值为 0.
value/styles.xml(对于值 11,我使用 "android:actionBarSize")
<style name="AppTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">@style/Widget.AppTheme.ActionBar</item>
<item name="actionBarSize">48dip</item>
</style>
代码:
getSupportActionBar().getHeight()
这没用?
// Calculate ActionBar height
TypedValue tv = new TypedValue();
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
{
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics());
}
参考:How to get the ActionBar height?
我正在寻找获取我的操作栏 (sherlock) 的高度。返回值为 0.
value/styles.xml(对于值 11,我使用 "android:actionBarSize")
<style name="AppTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">@style/Widget.AppTheme.ActionBar</item>
<item name="actionBarSize">48dip</item>
</style>
代码:
getSupportActionBar().getHeight()
这没用?
// Calculate ActionBar height
TypedValue tv = new TypedValue();
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
{
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics());
}
参考:How to get the ActionBar height?