用于为Android MotionLayout提供附加功能的库

用于为Android MotionLayout提供附加功能的库

Android 布局(Layout)

访问GitHub主页

共26Star

详细介绍

Dynamic Motion

License Build Status Download

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

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:0.4.0'
}

Usage

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

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 ViewPager.OnPageChangeListener);

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

GitHub Follow on Twitter Donate via PayPal


License

Copyright 2018-2020 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.
推荐源码