4

I am trying to rotate the framelayout containing the 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's rotating ok...but the problem is that any clickable area in the webview is not changing it's coordinates according to the rotated coordinate system of the layout. Also the scroll of the webview is getting reversed

Any suggestion on how to fix this problem

  • Maybe you need something like the touch event code [here](http://stackoverflow.com/q/3444764/931277). – dokkaebi Jan 25 '12 at 08:11

1 Answers1

0

I have had similar problems with being able to activate part of a UI while an animation was running even though there is "nothing" there. The RotateAnimation you are using only updates the visuals of the view, all of the FrameLayouts elements remain intact in their original locations.

One possibility is to create a separate layout for your FrameLayout that is set up to look like the view post-rotation. This layout can be instantiated in your Activity by Implementing Animation.AnimationListener and putting the instantiation code in the onAnimationEnd(Animation) method.

Baased on your setDuration(int) value of 0, it looks like you may not even care about seeing the view animated at all. In this case you could just replace the code that starts your LayoutAnimation with the code that replaces the layout.

happydude
  • 3,869
  • 2
  • 23
  • 41