How to disable transitions

133 views
Skip to first unread message

ser...@gmail.com

unread,
May 27, 2013, 5:11:44 AM5/27/13
to codenameone...@googlegroups.com
I want to disable transitions when the form is shown or navigated. I have done that by 

protected void beforeMainForm(Form f) {
        f.setTransitionInAnimator(null);
        f.setTransitionOutAnimator(null);
        f.setBackCommand(null);
        f.removeAllCommands();
}

But it does not help.

Shai Almog

unread,
May 27, 2013, 12:11:45 PM5/27/13
to codenameone...@googlegroups.com, ser...@gmail.com
Null will install the default transition from the look and feel. If you want to remove transitions from the theme you can define the transitionOut slide to be empty in the theme.
Or you can use the setter in the look and feel class to set transition out to null.

Or if you want to do this one form at a time (as you did here) then you need to set transition out to CommonTransitions.createEmpty() to override the global defaults.

ser...@gmail.com

unread,
May 27, 2013, 2:42:57 PM5/27/13
to codenameone...@googlegroups.com, ser...@gmail.com
I tried in 
public void init(Object context):
        UIManager.getInstance().getLookAndFeel().setDefaultFormTransitionIn(null);
        UIManager.getInstance().getLookAndFeel().setDefaultFormTransitionOut(null);

and also 

        UIManager.getInstance().getLookAndFeel().setDefaultFormTransitionIn(CommonTransitions.createEmpty());
        UIManager.getInstance().getLookAndFeel().setDefaultFormTransitionOut(CommonTransitions.createEmpty());

but it did not have any effect.
So for each form I had to execute:

        form.setTransitionInAnimator(CommonTransitions.createEmpty());
        form.setTransitionOutAnimator(CommonTransitions.createEmpty());

which worked fine. 

It would be nice to setup one time in the code as you mentioned. But I guess I did not do that right with LookAndFeel class.

Shai Almog

unread,
May 28, 2013, 1:08:24 AM5/28/13
to codenameone...@googlegroups.com, ser...@gmail.com
Init happens before the theme is loaded. You should either add the theme constant in the designer tool as I suggested (just load the theme and go to the constants tab, press "Add").
Or override the initTheme method and make the changes after the call to super.

Shai Almog

unread,
May 28, 2013, 1:09:56 AM5/28/13
to codenameone...@googlegroups.com, ser...@gmail.com
Sorry I was answering for a GUI builder application with regard to the init method, if you have a non-gui builder application you should see the theme loading code right there and place your logic after that. (the theme constant portion of my answer is accurate for both cases).

ser...@gmail.com

unread,
May 28, 2013, 4:00:23 AM5/28/13
to codenameone...@googlegroups.com, ser...@gmail.com
Shai, 

I added constant in GUI builder. I could not find transitionOut in the drop down, so I added it manually. I also added dialogTransitionIn and dialogTransitionOut to be empty. But it still does not work.

Shai Almog

unread,
May 28, 2013, 11:03:05 AM5/28/13
to codenameone...@googlegroups.com, ser...@gmail.com
Its form transition out or something like that, its in the combo when you are in the constants tab!

ser...@gmail.com

unread,
May 28, 2013, 3:38:34 PM5/28/13
to codenameone...@googlegroups.com, ser...@gmail.com
Yes formTransitionOut

Here is the simple res file that I created

You don't have to check it, but there could be a bug so you might want to fix it.

Shai Almog

unread,
May 29, 2013, 1:10:15 AM5/29/13
to codenameone...@googlegroups.com, ser...@gmail.com
The docs are missing there, you need to define it as "empty" (no quotes) not leave it as an empty string. We need to update that information.
Reply all
Reply to author
Forward
0 new messages