我正在尝试在 android 中旋转包含 webview 的框架布局,这是我的代码:
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);
旋转正常...但问题是 webview 中的任何可点击区域都没有根据布局的旋转坐标系更改其坐标。 webview 的滚动也正在反转
关于如何解决这个问题的任何建议
最佳答案
我遇到过类似的问题,即在动画运行时能够激活 UI 的一部分,即使那里“什么都没有”。您使用的 RotateAnimation
仅更新 View 的视觉效果,所有 FrameLayout
的元素都在其原始位置保持不变。
一种可能性是为您的 FrameLayout
创建一个单独的布局,设置为看起来像旋转后的 View 。通过实现 Animation.AnimationListener
并将实例化代码放在 onAnimationEnd(Animation)
方法中,可以在您的 Activity
中实例化此布局。
根据您的 setDuration(int)
值为 0,看起来您可能根本不关心看到动画 View 。在这种情况下,您可以将启动 LayoutAnimation
的代码替换为替换布局的代码。
关于android - Android中包含webview的FrameLayout旋转90度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8999357/