【问题标题】:Android actionbarsherlock get height return 0Android actionbarsherlock 获取高度返回 0
【发布时间】:2015-03-15 07:22:44
【问题描述】:

我正在寻找获取我的操作栏(夏洛克)的高度。返回值为0。

value/styles.xml(对于 value11,我使用了“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()

【问题讨论】:

  • 你在哪里打电话给getSupportActionBar().getHeight()
  • @puj 在 setContentView() 之后
  • @puj 我已经看到了,我做了同样的事情,但它不起作用

标签: android android-actionbar height actionbarsherlock


【解决方案1】:

这不起作用?

// 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?

【讨论】:

  • 您的视图布局后是否尝试过?例如,在onResume?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-20
  • 1970-01-01
  • 1970-01-01
  • 2010-12-05
  • 1970-01-01
  • 2015-09-02
相关资源
最近更新 更多