It's 0 because in both onCreate and onStart, the view hasn't actually been drawn yet. You can get around this by listening for when the view is actually drawn:

final TextView tv =(TextView)findViewById(R.id.venueLabel);
final ViewTreeObserver observer = tv.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener()
{
  @Override
  publicvoid onGlobalLayout()
{
tv.getHeight();
observer.removeGlobalOnLayoutListener(this);
  }
});

The call to remove the listener is there to prevent repeated invocations of your custom handler on layout changes... if you want to get those, you can omit it.

http://stackoverflow.com/questions/8170915/getheight-returns-0-for-all-android-ui-objects

最新文章

  1. 轻量级前端MVVM框架avalon - 模型转换
  2. 关于本月第一天,本月最后一天的SQL代码
  3. C++ 中数串互转、进制转换的类
  4. FZU 2191 完美的数字
  5. 严重: The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it.
  6. ECNU1104-BFS
  7. asp.net中应用JQuery.pagination分页
  8. Java代理模式——静态代理模式
  9. SQLServer,仅当使用了列列表并且 IDENTITY_INSERT 为 ON 时,才能为表xx中的标识列指定显式值
  10. [转载]LVS快速搭建教程
  11. Kafka 使用Java实现数据的生产和消费demo
  12. LeetCode & Q88-Merge Sorted Array-Easy
  13. 【转】Mac 删除文件夹里所有的.svn文件
  14. loadrunner脚本函数讲解
  15. DAY15 模块
  16. Android开发之adb,$Sqlite篇
  17. java使用freemarker模板导出word(带有合并单元格)文档
  18. ES6箭头函数this指向
  19. C语言复习---迭代法,牛顿迭代法,二分法求根
  20. .NetCore下使用Prometheus实现系统监控和警报 (一)介绍【译】

热门文章

  1. OpenShare文档中心
  2. MySQLdb模块安装-win环境
  3. cocos2dx注册场景 使用CCEditBox实现输入框
  4. 20150309--gridview
  5. ES6新增Promise
  6. poj 3268 Silver Cow Party
  7. gcc常用命令介绍
  8. zedboard 驱动理解
  9. 批处理cmd背景颜色
  10. 设置Linux时间 同步时间