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);
}
}
});
本文介绍如何使用ViewTreeObserver实现获取屏幕高度,并根据获取到的高度调整滚动视图的位置,确保用户界面的流畅性和用户体验。
532

被折叠的 条评论
为什么被折叠?



