addOnGlobalLayoutListener的接口的回调方法执行顺序问题

  mTv_des.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                mDescHeight = mTv_author.getHeight();
                Log.d("AppDetailDesc", "mDescHeight:" + mDescHeight);
                if (mDescHeight > 0) {
                    mTv_des.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    mTv_des.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                        @Override
                        public void onGlobalLayout() {
                            mHeight_5 = mTv_des.getHeight();
                            Log.d("AppDetailDesc", "mHeight_5:" + mHeight_5);
                            if (mHeight_5 > 0) {
                                mTv_des.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                            }
                        }
                    });
                    mTv_des.setMaxLines(5);
                }
            }
        });

代码的逻辑是设置监听,完成绘制后获取textview的高度,然后取消后重新设置监听,改变textview的最大行数,完成绘制触发监听获取5行的高度。

但是实际的执行是:

D/AppDetailDesc: bindView
D/AppDetailDesc: mDescHeight:56
D/AppDetailDesc: mHeight_5 : 250

对这样实际逻辑难以理解,有没有大神可以解答一下!谢谢啦~

http://blog.csdn.net/hualizide/article/details/43938029