0

I am using this to measure view size:

int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(toExpandVystrahy.getWidth(), View.MeasureSpec.EXACTLY);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
textVystrahy.measure(widthMeasureSpec, heightMeasureSpec);
int vystrahyHeight = textVystrahy.getMeasuredHeight();

I have this code in my onActivityCreated inside fragment. It works great and measures correctly when I first start my application. However when I change screen orientation and run this method from onActivityCreated inside fragment it still returns the same value like before rotation. So where should I measure view height after screen rotation? Isnt onActivityCreated correct place?

Thanks in forward

horin
  • 1,664
  • 6
  • 23
  • 52

1 Answers1

0

In your Custom View override onMeasure method and get the size of you View with getMeasuredWidth() and getMeasuredHeight()

I do something like this.

    @Override
    protected void onMeasure(int width, int height) {
        super.onMeasure(width,height);
        int w = getMeasuredWidth();
        int h = getMeasuredHeight();
    }