Dynamic Motion

Additional

Language
Java
Version
v1.1.0 (Jul 14, 2023)
Created
Nov 3, 2018
Updated
Dec 7, 2023
Owner
Pranav Pandey (pranavpandey)
Contributor
Pranav Pandey (pranavpandey)
1
Activity
Badge
Generate
Download
Source code

Dynamic Motion

A library to provide additional functionality for MotionLayout on Android 4.3 (API 18) and above.

Since v1.0.0, it is dependent on Java 8.
Since v1.1.0, it is targeting Java 17 to provide maximum compatibility.

It has DynamicMotionLayout which has a built-in ViewPager to create parallax effects which will open a huge set of possibilities for the original MotionLayout.


Contents


Installation

It can be installed by adding the following dependency to your build.gradle file:

dependencies {
    implementation 'com.pranavpandey.android:dynamic-motion:1.1.0'
}

Usage

It is divided into 3 simple steps and whole layout can be configured by just using the xml files.

For a complete reference, please read the documentation.

Replace

First, replace the original MotionLayout with DynamicMotionLayout in xml file.

<com.pranavpandey.android.dynamic.motion.widget.DynamicMotionLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    ...
    >

    ...
</com.pranavpandey.android.dynamic.motion.widget.DynamicMotionLayout>

Page count

Set page count for ViewPager to divide the transition between different pages.

<com.pranavpandey.android.dynamic.motion.widget.DynamicMotionLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:adm_pageCount="4"
    ...
    >

    ...
</com.pranavpandey.android.dynamic.motion.widget.DynamicMotionLayout>
// At runtime
dynamicMotionLayout.setPageCount(int, @Nullable ViewPager2.OnPageChangeCallback);

Motion scene

Add a motion scene and use KeyFrameSet and KeyAttribute to animate the views across different pages. Please check the sample for a demo scene.

<com.pranavpandey.android.dynamic.motion.widget.DynamicMotionLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:layoutDescription="@xml/motion_scene"
    app:adm_pageCount="4"
    ...
    >

    ...
</com.pranavpandey.android.dynamic.motion.widget.DynamicMotionLayout>

Author

Pranav Pandey


License

Copyright 2018-2023 Pranav Pandey

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.