代号一:表单更改时奇怪的工具栏动画 [英] Codename One: Strange toolbar animation on form change
问题描述
由于在表单中添加了全局工具栏,因此在更改表单时会出现一个奇怪的动画错误(?)。在FormA上单击一个按钮,该按钮将调用FormB.show()时,标题具有动画,使新表单从右至左在工具栏区域中口吃。谷歌搜索后,我发现
这几乎是我在工具栏上遇到的问题,唯一的区别是我添加的工具栏徽标到中心的位置从右到左结结巴巴。动画完成后,表单看起来应该像它应该的样子。
主要是这样:
Toolbar.setGlobalToolbar(true);
在每种形式中,我在构造函数中执行以下操作:
menuForm = new Form(,new BorderLayout());
logo = res_theme.getImage( Logo_Gema_vertikal.png);
menuForm.getToolbar()。getTitleComponent()。setUIID( toolbar_image);
((Label)menuForm.getToolbar()。getTitleComponent())。setIcon(logo);
menuForm.getToolbar()。addCommandToSideMenu(homeCommand);
menuForm.getToolbar()。getMenuBar()。addCommand(homeCommand);
如果我没有在工具栏上添加徽标,则只有命令图标从右侧向左边。是什么原因造成的?我使用的工具栏错误吗?
从您的问题来看,这是由于使用了默认动画 createSlideFadeTitle
。您可以通过将当前表单和目标表单的动画更改为 createCover
或 createSlide
来解决此问题:
当前格式:
currentForm.setTransitionOutAnimator(CommonTransitions.createSlide( CommonTransitions.SLIDE_HORIZONTAL,false,300));
nextForm.show();
并以目标形式:
nextForm.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL,false,300));
currentForm.showBack();
Since adding a global Toolbar to the forms there is a strange animation bug (?) when changing forms. At hitting a Button at FormA that will invoke FormB.show() the title has an animation the lets the new form stutter in the toolbar area from the right to the left. After googling I found this:
This is pretty much the problem I face at the toolbar, only difference is the toolbar Logo I added to the center is stuttering from the right to the left to its place. After the animation is done, the form looks just like it should.
In the main I do this:
Toolbar.setGlobalToolbar(true);
In every Form I do something like this in the constructor:
menuForm = new Form(" ", new BorderLayout());
logo = res_theme.getImage("Logo_Gema_vertikal.png");
menuForm.getToolbar().getTitleComponent().setUIID("toolbar_image");
((Label)menuForm.getToolbar().getTitleComponent()).setIcon(logo);
menuForm.getToolbar().addCommandToSideMenu(homeCommand);
menuForm.getToolbar().getMenuBar().addCommand(homeCommand);
If I leave out adding the logo to the toolbar, only the Command Icons are flying from the right to the left. What is causing this? Am I using the toolbar wrong?
From your question, it's due to using the default animation which is createSlideFadeTitle
. You can solve this by changing the animation of the current form and the destination form to either createCover
or createSlide
:
In the current form:
currentForm.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 300));
nextForm.show();
And in the destination form:
nextForm.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 300));
currentForm.showBack();
这篇关于代号一:表单更改时奇怪的工具栏动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!