当前位置:操作系统 > 安卓/Android >>

Android中在OnCreate时获得控件高度

 

ViewTreeObserver vto = mArrowUp.getViewTreeObserver(); 

        vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { 

            @Override 

            public void onGlobalLayout() { 

                mArrowUp.getViewTreeObserver().removeGlobalOnLayoutListener(this); 

                Log.e("Width",Integer.toString(mArrowUp.getWidth())); 

                 

 

 

            } 

        });   

 

摘自 欧阳天涵的专栏

补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,