获取View高度的几种方式
2015-11-03 18:05
309 查看
http://www.jb51.net/article/64727.htm
http://www.cnblogs.com/taoweiji/p/3400891.html
ViewTreeObserver vto = tv.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
public void onGlobalLayout() {
heigh = appDescription.getHeight();
tv.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
});
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
mFlowDetailByPackages.measure(w, h);
vto = mDetailed.getViewTreeObserver();
heightTotal = mFlowDetailByPackages.getMeasuredHeight();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// TODO Auto-generated method stub
int heightView = mDetailed.getHeight();
mDetailed.getViewTreeObserver().removeGlobalOnLayoutListener(this);
if(heightTotal - heightView >0){
mRefreshListView.getRefreshableView().scrollTo(0, heightTotal-heightView);
}
}
});
http://www.cnblogs.com/taoweiji/p/3400891.html
ViewTreeObserver vto = tv.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
public void onGlobalLayout() {
heigh = appDescription.getHeight();
tv.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
});
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
mFlowDetailByPackages.measure(w, h);
vto = mDetailed.getViewTreeObserver();
heightTotal = mFlowDetailByPackages.getMeasuredHeight();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// TODO Auto-generated method stub
int heightView = mDetailed.getHeight();
mDetailed.getViewTreeObserver().removeGlobalOnLayoutListener(this);
if(heightTotal - heightView >0){
mRefreshListView.getRefreshableView().scrollTo(0, heightTotal-heightView);
}
}
});
相关文章推荐
- javaSE常用的方法总结
- Android 编程下 Touch 事件的分发和消费机制
- Strongly connected-HDU4635
- jquery checkbox checked 却不显示对勾
- Android--使用手机GPS获取经纬度
- JMX 和 管理系统简介(一)
- Cocos2d-x场景转换后局部变量值异常问题。
- HDU 5514 Frogs 容斥定理
- Deploy .Net project automatically with MsBuild and MsDeploy (0)
- 报表抽数据
- 开源性能测试工具 - Apache ab 介绍
- 20、ASP.NET MVC入门到精通——WebAPI
- Unity3d 制作动态Mesh且可以随地面凹凸起伏
- 百度地图离线API开发(真正的离线开发)
- 如何实现Android应用的启动画面(闪屏)?
- 帮你提升 Python 的 27 种编程语言
- 关于spring项目的单例测试
- hdu3714(三分)
- codeforces255E Furlo and Rublo and Game SG函数
- Mac—为任意操作添加快捷键