Rotate View Hierarchy 90 degrees

后端 未结 6 979
予麋鹿
予麋鹿 2020-11-28 03:33

I am working on a subclass of FrameLayout that is supposed to rotate all of its children by 90 degrees. I am doing this to overcome the landscape-only camera limitation pres

6条回答
  •  感动是毒
    2020-11-28 04:13

    I think you forgot one line in your onMeasure.

    @Override
    protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         super.onMeasure(heightMeasureSpec, widthMeasureSpec);
         setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
    }
    

    Taken from the code for a vertical seekbar here: How can I get a working vertical SeekBar in Android?

    You might need to fiddle with the getMeasuredHeight() to make it the correct size of your screen.

提交回复
热议问题