2010-11-17

android: Forcing View's onMeasure be called(by its parent)

Call child view's 'requestLayout()' function,

ex)

    public void toggleFillScreen() {
        fillScreen = !fillScreen;
        requestLayout();
    }
   
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (fillScreen == true) {
            int width = defaultDisplay.getWidth();
            int height = defaultDisplay.getHeight();
            Log.i(TAG, "defaultDisplay width=" + defaultDisplay.getWidth() + " height=" + defaultDisplay.getHeight());
            Log.i(TAG, "onMeasure width=" + width + " height=" + height);
            setMeasuredDimension(width, height);
        } else {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    }

Checking VideoView.java source at http://www.netmite.com/android/mydroid/frameworks/base/core/java/android/widget/VideoView.java will be helpful.

댓글 없음:

댓글 쓰기