我想将屏幕从 my_screen1 转换为 my_screen2 。想法是截取两个屏幕的截图,并使用动画从1转换到2.然后将my_screen2推送到显示堆栈。但是我可以在之前截取屏幕my_screen2 的屏幕截图吗? 代码:
Display.screenshot(bitmap);
显示已经的屏幕截图。是否有类似的东西:
my_screen2.screenshot(bitmap);
请问任何示例代码?非常感谢!
答案 0 :(得分:4)
您无法截取屏幕截图,该屏幕不在显示器堆栈上,也不在特定屏幕下方。文档说Display.screenshot()
获取整个屏幕的屏幕截图并将其保存到位图中。
如果您想让屏幕转换动画从一个屏幕转到另一个屏幕,您可以执行以下操作。
UiEngineInstance engine = Ui.getUiEngineInstance();
TransitionContext transitionContextPush = new TransitionContext(
TransitionContext.TRANSITION_SLIDE);
transitionContextPush.setIntAttribute(
TransitionContext.ATTR_DURATION, 150);
transitionContextPush.setIntAttribute(
TransitionContext.ATTR_DIRECTION,
TransitionContext.DIRECTION_LEFT);
TransitionContext transitionContextPop = new TransitionContext(
TransitionContext.TRANSITION_SLIDE);
transitionContextPop.setIntAttribute(
TransitionContext.ATTR_DURATION, 150);
transitionContextPop.setIntAttribute(
TransitionContext.ATTR_DIRECTION,
TransitionContext.DIRECTION_RIGHT);
transitionContextPop.setIntAttribute(
TransitionContext.ATTR_KIND,
TransitionContext.KIND_OUT);
engine.setTransition(null, thisScreen,
UiEngineInstance.TRIGGER_PUSH,
transitionContextPush);
engine.setTransition(thisScreen, null,
UiEngineInstance.TRIGGER_POP,
transitionContextPop);
}
UiApplication.getUiApplication().pushScreen(thisScreen);
答案 1 :(得分:4)
请参阅rahul_narkhede针对OS5之前的滑动屏幕过渡的解决方案,我过去已经成功使用过它。