• Stars
    star
    2,305
  • Rank 19,976 (Top 0.4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An expandable layout container for Android

ExpandableLayout

An Android layout class that supports animating the expansion and collapse of its child views.

I built this because all of the available libraries I tested were missing features or behaving unexpectedly in certain cases (e.g. rotation handling).

This library offloads as much work as possible to the parent layout to ensure that the rendering and size calculations behave as expected. This means that even complex features such as LinearLayout's weight tag are properly supported.

Try the demo

Google Play Store badge

Features

ExpandableLayout supports animating:

  • Views with fixed and variable heights:

simple

  • "Accordion" expansion (using two expandable layouts)

accordion

  • RecyclerView items

recycler

  • Horizontal expansion

horizontal

Usage

Add the Jitpack maven repository if you don't have it yet:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Reference the library from your module's build.gradle:

dependencies {
    [...]
    implementation 'com.github.cachapa:ExpandableLayout:2.9.2'
}

Add ExpandableLayout as a container to the layout or views you want to make expandable:

<net.cachapa.expandablelayout.ExpandableLayout
    android:id="@+id/expandable_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:el_duration="1000"
    app:el_expanded="true"
    app:el_parallax="0.5">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="16dp"
        android:text="Fixed height" />

</net.cachapa.expandablelayout.ExpandableLayout>

Also supported are el_duration and el_expanded tags, for specifying the duration of the animation and whether the layout should start expanded, respectively. el_parallax can be set to a value between 0 and 1 to control how the child view is translated during the expansion.

To trigger the animation, simply grab a reference to the ExpandableLayout from your Java code and and call either of expand(), collapse() or toggle().

A full demo of the library is included with the project.

License

Copyright 2016 Daniel Cachapa.

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.

Footnotes

Gifs were generated using the following script: https://gist.github.com/cachapa/aa829bfc717fc4f1d52c568d7ae8521e

More Repositories

1

firedart

A dart-native implementation of the Firebase Auth and Firestore SDKs
Dart
174
star
2

crdt

Dart implementation of Conflict-free Replicated Data Types (CRDTs)
Dart
137
star
3

AerialDream

A screensaver for Android inspired on the one from the Apple TV
Java
112
star
4

tudo

A simple to-do app
JavaScript
66
star
5

sql_crdt

Dart implementation of Conflict-free Replicated Data Types (CRDTs) using SQL databases
Dart
48
star
6

sqlite_crdt

Dart implementation of Conflict-free Replicated Data Types (CRDTs) using Sqlite
Dart
26
star
7

RemoteGallery

Access your SSH-hosted pictures remotely from your Android device
Java
18
star
8

hive_crdt

A CRDT backed by a Hive store
Dart
16
star
9

BottomNavigation

An implementation of the Material Design Bottom Navigation Drawer for Android
Java
15
star
10

crdt_sync

A dart-native turnkey solution for painless network synchronization
Dart
11
star
11

tudo_server

A simple to-do app server
Dart
10
star
12

crdt_draw

A collaborative real-time local-first global canvas
Dart
10
star
13

postgres_crdt

Dart implementation of Conflict-free Replicated Data Types (CRDTs) using PostgreSQL
Dart
10
star
14

SAM-Java

An example of the SAM (State-Action-Model) pattern in Java/Android
Java
7
star
15

ottobot

A Mattermost bot
Dart
6
star
16

BusinessTime

Simple work time counter, designed for automation
Java
6
star
17

crdt_server

Generic REST server based on Conflict-free Replicated Data Types (CRDTs)
Dart
5
star
18

tonie_shuffle

A command-line utility to shuffle Creative Tonie playlists
Dart
4
star
19

mattermost_dart

A basic implementation of the Mattermost API in dart
Dart
4
star
20

fireutil

Utility to manage Firestore databases
Dart
3
star
21

Protium-Demo

A demonstration of the Protium architecture
Java
2
star