All Projects → florent37 → Expansionpanel

florent37 / Expansionpanel

Licence: apache-2.0
Android - Expansion panels contain creation flows and allow lightweight editing of an element.

Programming Languages

java
68154 projects - #9 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Expansionpanel

Shapeofview
Give a custom shape to any android view, Material Design 2 ready
Stars: ✭ 2,977 (+50.05%)
Mutual labels:  material, view, layout, androidx
Readablebottombar
Yet another material bottom bar library for Android
Stars: ✭ 977 (-50.76%)
Mutual labels:  material, view, layout
Arclayout
With Arc Layout explore new styles and approaches on material design
Stars: ✭ 1,662 (-16.23%)
Mutual labels:  material, view, layout
Physicslayout
Android layout that simulates physics using JBox2D
Stars: ✭ 658 (-66.83%)
Mutual labels:  view, layout
Kotlinpleaseanimate
Kotlin, please, can you animate my views ?
Stars: ✭ 541 (-72.73%)
Mutual labels:  material, view
Longshadow
Add a long shadow on any Android View
Stars: ✭ 562 (-71.67%)
Mutual labels:  view, layout
Bouncylayout
Make. It. Bounce.
Stars: ✭ 4,035 (+103.38%)
Mutual labels:  view, layout
Androidlibs
🔥正在成为史上最全分类 Android 开源大全~~~~(长期更新 Star 一下吧)
Stars: ✭ 7,148 (+260.28%)
Mutual labels:  view, layout
Ringprogressbar
A material design circle the progress bar.
Stars: ✭ 789 (-60.23%)
Mutual labels:  material, view
Viewtooltip
A fluent tooltip for Android
Stars: ✭ 1,029 (-48.14%)
Mutual labels:  material, view
Kvconstraintkit
An Impressive Auto Layout DSL for iOS, tvOS & OSX. & It is written in pure swift.
Stars: ✭ 91 (-95.41%)
Mutual labels:  view, layout
Bubbletab
Put some bubble in your tabs and give your apps a supa fresh style !
Stars: ✭ 537 (-72.93%)
Mutual labels:  material, layout
Materialtimelineview
With MaterialTimelineView you can easily create a material looking timeline.
Stars: ✭ 443 (-77.67%)
Mutual labels:  material, view
Chips Input Layout
A customizable Android ViewGroup for displaying Chips (specified in the Material Design Guide).
Stars: ✭ 591 (-70.21%)
Mutual labels:  material, view
Mylinearlayout
MyLayout is a powerful iOS UI framework implemented by Objective-C. It integrates the functions with Android Layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,PathLayout,GridLayout,LayoutSizeClass to build your App 自动布局 UIView UITab…
Stars: ✭ 4,152 (+109.27%)
Mutual labels:  view, layout
Kotlinanim
Create fluent animations in a kotlin way
Stars: ✭ 72 (-96.37%)
Mutual labels:  view, layout
Bannerlayout
Support unlimited picture rotation BannerLayout, the minimum implementation of the code banner
Stars: ✭ 92 (-95.36%)
Mutual labels:  view, layout
Scalinglayout
With Scaling Layout scale your layout on user interaction.
Stars: ✭ 3,276 (+65.12%)
Mutual labels:  view, layout
Materialimageloading
Material image loading implementation
Stars: ✭ 396 (-80.04%)
Mutual labels:  material, view
Fiftyshadesof
An elegant context-care loading placeholder for Android
Stars: ✭ 1,110 (-44.05%)
Mutual labels:  material, view

ExpansionPanel

Expansion panels contain creation flows and allow lightweight editing of an element.

AndroidX Ready

Based on Expansion Panels described on Material Design Components https://material.io/archive/guidelines/components/expansion-panels.html#

screen

Android app on Google Play

screen

Download

Buy Me a Coffee at ko-fi.com

Download

dependencies {
    implementation 'com.github.florent37:expansionpanel:1.2.4'
}

Usage

<LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:orientation="vertical"
    >

    <com.github.florent37.expansionpanel.ExpansionHeader
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        app:expansion_headerIndicator="@id/headerIndicator"
        app:expansion_layout="@id/expansionLayout"
        app:expansion_toggleOnClick="true">

        <!-- HEADER -->

        ...
        <!-- HEADER INDICATOR -->
        <ImageView
               android:adjustViewBounds="true"
               android:id="@+id/headerIndicator"
               android:layout_gravity="center_vertical|right"
               android:layout_height="wrap_content"
               android:layout_marginLeft="16dp"
               android:layout_width="wrap_content"
               app:srcCompat="@drawable/ic_expansion_header_indicator_grey_24dp" />


    </com.github.florent37.expansionpanel.ExpansionHeader>

    <com.github.florent37.expansionpanel.ExpansionLayout
        android:id="@+id/expansionLayout"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">

        <!-- CONTENT -->

    </com.github.florent37.expansionpanel.ExpansionLayout>
</LinearLayout>

Header

  1. Connect with his Expansion Layout : expansion_layout (they must have the same parent)
  2. Define the indicator view with expansion_headerIndicator (the id of a view inside the header)
  3. If you want to expand/close when the header is clicked, setup expansion_toggleOnClick
  4. You can modify the indicator rotation with expansion_headerIndicatorRotationExpanded and expansion_headerIndicatorRotationCollapsed

Layout

You can modify the default expansion of the label with `app:expansion_expanded="false"

Layout can be toggled programmatically with .toggle()

Use .setEnable(true/false) to enable/disable the expansion

Listener

Just add a listener into ExpansionLayout (not the header !) to follow the expansion layout state

ExpansionLayout expansionLayout = findViewById(...);
expansionLayout.addListener(new ExpansionLayout.Listener() {
    @Override
    public void onExpansionChanged(ExpansionLayout expansionLayout, boolean expanded) {

    }
});

Open only one

screen

You can setup multiple expansions layout to enable only 1 opened at time

final ExpansionLayoutCollection expansionLayoutCollection = new ExpansionLayoutCollection();
expansionLayoutCollection.add(ex1);
expansionLayoutCollection.add(ex2);

expansionLayoutCollection.openOnlyOne(true);

or direcly in xml with

  • ExpansionsViewGroupLinearLayout
  • ExpansionsViewGroupFrameLayout
  • ExpansionsViewGroupRelativeLayout
  • ExpansionsViewGroupConstraintLayout
<com.github.florent37.expansionpanel.viewgroup.ExpansionsViewGroupLinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:expansion_openOnlyOne="true"
                android:orientation="vertical">

                <!-- Expansions Header & Layouts -->

</com.github.florent37.expansionpanel.viewgroup.ExpansionsViewGroupLinearLayout>

Horizontal

Simply use HorizontalExpansionLayout instead of ExpansionLayout

<com.github.florent37.expansionpanel.HorizontalExpansionLayout
        android:id="@+id/expansionLayout"
        android:layout_height="wrap_content"
        android:layout_width="match_parent">

        <!-- CONTENT -->

</com.github.florent37.expansionpanel.HorizontalExpansionLayout>

RecyclerView

Sample: https://github.com/florent37/ExpansionPanel/blob/master/app/src/main/java/florent37/github/com/expansionpanel/ExpansionPanelSampleActivityRecycler.java

public class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerHolder> {

    ...

    //add an ExpansionLayoutCollection to your recycler adapter
    private final ExpansionLayoutCollection expansionsCollection = new ExpansionLayoutCollection();


    @Override
    public void onBindViewHolder(MyRecyclerHolder holder, int position) {
        //bind your elements

        //just add the ExpansionLayout (with findViewById) to the expansionsCollection
        expansionsCollection.add(holder.getExpansionLayout());
    }
}

Single Listener

Update gradle, add ability to have only one listener at time

For what? If you tried to debug ViewHolders with this layout, then you might notice that over time addListener continues to add a listener, which causes a lot of unnecessary listeners and, moreover, there can be many listeners to one layouts in different ViewHolders due to which it may cause logic breakdown

var isExpanded = false

expandableLayout.run {
    //expandableLayout.singleListener = true
    singleListener = true

    expandableLayout.addListener { expansionLayout, expanded ->
        isExpanded = expanded
    }

    //do not toggle (expand/collapse, etc) before add listener

    if (isExpanded)
        expand(false)
    else
        collapse(false)
}

Credits

Author: Florent Champigny

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2017 Florent37, Inc.

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].