0
votes

how to chain onSizeChanged(),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

1
why can't you use match_parent, so you know, you can match your parent? - Bryan Mills

1 Answers

0
votes

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);
            }
        });