使用 ViewSwitcher 开始时的 Android 焦点问题
所以我正在开发一个 Android 应用程序,它是一个非常简单的应用程序,现在只有 2 个使用 ViewSwitcher 进行切换的视图。每个页面上都有一个用于切换视图的按钮。无论出于何种原因,在应用程序启动时使用带有过渡(平滑平移动画)的 ViewSwitcher 按钮都无法正确触发按钮按下事件。
无论出于何种原因,他们都会将它们排队,直到活动经历 onPause / onResume 周期,然后他们将触发所有排队的事件。仅当 ViewSwitcher 附加动画时才会发生这种情况。如果我不设置任何动画并且视图立即切换,则不会发生这种情况。它看起来像是某种低级错误,动画在第一次启动时永远阻塞。
这就是我创建动画的方式:
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(animDuration);
inFromRight.setInterpolator(new AccelerateInterpolator());
从网上获取样本。有什么想法如何解决这个问题吗?我不想让用户退出并重新进入应用程序以获得工作按钮。
谢谢!
So I'm developing an Android App, it's a very simple app right now just 2 views which are switch using a ViewSwitcher. On each page there is a button to switch the views. For whatever reason the using the ViewSwitcher with an transition (smooth panning animation) on the start of the app the buttons don't correctly fire off their button pressed events.
For whatever reason they queue them up until the activity goes through a onPause / onResume cycle then they will fire all their queued events. This only happens if there is an attached animation with the ViewSwitcher. If i don't set any animation and the view switches instantly this doesn't happen. It looks like to be some sort of low level bug with the animation blocking forever on first startup.
This is how i create the animation :
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(animDuration);
inFromRight.setInterpolator(new AccelerateInterpolator());
Taken off a sample from the net. Any ideas how to fix this? I rather not have the user exit and re-enter the app to get working buttons.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论