14

I'm using Transitions-Everywhere for my app, and I wonder if I can set the transition speed/time of the transitions..

I have something like this:

TransitionManager().beginDelayedTransition(animLayout, new ChangeBounds());

FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) findViewById(R.id.myId).getLayoutParams();
layoutParams.height = (int) myHeight;
layoutParams.width = (int) myWidth;
myLayout.setLayoutParams(layoutParams);

In short, I want the transition to be slower than the default, but I just can't figure out how to set the speed of the transition!

Xaver Kapeller
  • 49,491
  • 11
  • 98
  • 86
johnguild
  • 435
  • 1
  • 5
  • 25

2 Answers2

25

You can set the duration on the Transition you pass into beginDelayedTransition(). In your case that would be ChangeBounds. So try something like this:

final ChangeBounds transition = new ChangeBounds();
transition.setDuration(600L); // Sets a duration of 600 milliseconds
TransitionManager().beginDelayedTransition(animLayout, transition);

By default if no duration is set a Transition falls back to the default animation duration which is 300ms. So for example if you want the transition to take twice as long, use 600ms.

Xaver Kapeller
  • 49,491
  • 11
  • 98
  • 86
  • exactly what i needed, thanks a lot, by the way i did looked at some animation classes in the library but couldn't find the setDuration method, mind telling me where can i look it, i'm new to programming and open source so still grasping in reading libraries.. – johnguild Dec 16 '15 at 00:07
0
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        this.defaultPeekHeight = Resources.getSystem().displayMetrics.heightPixels / 4
        bottomSheetBehavior.peekHeight = defaultPeekHeight
        presenter.loadItems()
    }

    override fun onItemsLoaded(
        items: List<RecyclerItem<*>>
    ) {
        updateItems(items)
        b.root.doOnLayout {
            //animate expanding of bottom sheet
            val transition = ChangeBounds()
            transition.duration = ANIMATION_DURATION
            TransitionManager.beginDelayedTransition(b.draggableBottomSheetLayout, transition)
            bottomSheetBehavior.peekHeight = max(b.root.height, defaultPeekHeight)
        }}
yozhik
  • 4,644
  • 14
  • 65
  • 98