开发者

how to chain onSizeChanged(),onMeasure(),onDraw() in custom view class

how to chain onSizeChang开发者_StackOverflow社区ed(),onMeasure(),onDraw() in custom view class so I can get parent width amd parent height, so that I can scale my image to be fit exactly into the screen...kindly give any suitable example


Add this to your activity's onCreate

ViewTreeObserver vto        =   layout.getViewTreeObserver();
        vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                You should be able to get the width and height
                over here.

                layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }
        });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜