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.
Since v1.2.0, the minimum SDK is Android 4.4 (API 19) to comply with the latest policies.
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
.
It can be installed by adding the following dependency to your build.gradle
file:
dependencies {
implementation 'com.pranavpandey.android:dynamic-motion:1.2.0'
}
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.
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>
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);
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>
Pranav Pandey
Copyright 2018-2024 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.