90 degree rotation of FrameLayout containing Android webview

I am trying to rotate a framelayout containing a webview in android, here is my code:

FrameLayout contentView = (FrameLayout) getRootView().findViewById( R.id.content); FrameLayout backGround = new FrameLayout(getContext()); FrameLayout.LayoutParams bgfl = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT); backGround.addView(WebView object); contentView.addView(backGround, bgfl); RotateAnimation r = new RotateAnimation(0f, -90f,Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,0.5f); r.setDuration(0); r.setFillAfter(true); LayoutAnimationController animController = new LayoutAnimationController(r, 0); backGround.setLayoutAnimation(animController); 

It rotates normally ... but the problem is that any interactive area in the web view does not change its coordinates in accordance with the rotated coordinate system of the layout. In addition, web scrolling is viewed from the back.

Any suggestion on how to fix this problem

+4
source share
1 answer

I had similar problems with the ability to activate part of the user interface while the animation was running, even if there was nothing there. RotateAnimation that you use only updates the visuals, all FrameLayout elements remain intact in their original places.

One possibility is to create a separate layout for your FrameLayout , which is configured to look like a view after rotation. This layout can be created in Activity by implementing the Animation.AnimationListener and put the instance code in the onAnimationEnd(Animation) method.

When using setDuration(int) value of 0, it looks like you don’t even care to see the animated view. In this case, you can simply replace the code that launches your LayoutAnimation with the code that replaces the layout.

0
source

Source: https://habr.com/ru/post/1392865/


All Articles