expandableConstraintLayout

Additional

Language
Kotlin
Version
2.1.0 (Oct 29, 2018)
Created
Sep 18, 2017
Updated
Oct 29, 2018 (Retired)
Owner
Ricardo Vieira (rjsvieira)
Contributor
Ricardo Vieira (rjsvieira)
1
Activity
Badge
Generate
Download
Source code

ExpandableConstraintLayout

Description

The ExpandableConstraintLayout presents itself as a wrapper around Google's ConstraintLayout with the small feature of toggling (expansion/collapse). This class was implemented based on @cmfsotelo's idea of ExpandableLinearLayout

Project Inclusion

Include it in your project
  1. In your root/build.gradle
allprojects {
  repositories {
  ...
  maven { url 'https://jitpack.io' }
  }
}
  1. In your app/build.gradle
dependencies {
  compile 'com.github.rjsvieira:expandableConstraintLayout:1.0.0'
}

Initialization

Initialize your ExpandaConstraintLayout just like any other ConstraintLayout

ExpandableConstraintLayout ecl = (ExpandableConstraintLayout) findViewById(R.id.ecl);

Configuration

The user can define the duration of the expansion/collapse as well as the Interpolator used to animate the values
void setInterpolator(TimeInterpolator interpolator)
void setAnimationDuration(int animationDuration)

Interaction

The interaction methods are really basic and intuitive. In short, they stand for :
void toggle()
void expand()
void collapse()

Listener

The ExpandableConstraintLayout allows the implementation of a listener :

setAnimationListener(@NonNull ExpandableConstraintLayoutListener listener)

This listener will track the following events :

/**
* Notifies the start of the animation.
* Sync from android.animation.Animator.AnimatorListener.onAnimationStart(Animator animation)
*/
void onAnimationStart(ExpandableConstraintLayoutStatus status);

/**
* Notifies the end of the animation.
* Sync from android.animation.Animator.AnimatorListener.onAnimationEnd(Animator animation)
*/
void onAnimationEnd(ExpandableConstraintLayoutStatus status);

/**
* Notifies the layout is going to open.
*/
void onPreOpen();

/**
* Notifies the layout is going to equal close size.
*/
void onPreClose();

/**
* Notifies the layout opened.
*/
void onOpened();

/**
* Notifies the layout size equal closed size.
*/
void onClosed();