{"id":13493496,"url":"https://github.com/florent37/ExpansionPanel","last_synced_at":"2025-03-28T11:32:49.299Z","repository":{"id":47699529,"uuid":"116387327","full_name":"florent37/ExpansionPanel","owner":"florent37","description":"Android - Expansion panels contain creation flows and allow lightweight editing of an element.","archived":true,"fork":false,"pushed_at":"2020-07-02T11:51:19.000Z","size":937,"stargazers_count":1974,"open_issues_count":32,"forks_count":240,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-01-17T20:38:04.702Z","etag":null,"topics":["android","androidx","close","expansion","expansion-panels","layout","material","open","toggle","view"],"latest_commit_sha":null,"homepage":"https://material.io/guidelines/components/expansion-panels.html","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/florent37.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"ko_fi":"FlorentChampigny","github":"florent37"}},"created_at":"2018-01-05T13:21:53.000Z","updated_at":"2025-01-07T05:51:05.000Z","dependencies_parsed_at":"2022-08-17T15:35:45.113Z","dependency_job_id":null,"html_url":"https://github.com/florent37/ExpansionPanel","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FExpansionPanel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FExpansionPanel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FExpansionPanel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FExpansionPanel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/florent37","download_url":"https://codeload.github.com/florent37/ExpansionPanel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246021450,"owners_count":20710940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","androidx","close","expansion","expansion-panels","layout","material","open","toggle","view"],"created_at":"2024-07-31T19:01:15.868Z","updated_at":"2025-03-28T11:32:48.957Z","avatar_url":"https://github.com/florent37.png","language":"Java","readme":"# ExpansionPanel\nExpansion panels contain creation flows and allow lightweight editing of an element.\n\n*AndroidX Ready*\n\nBased on `Expansion Panels` described on Material Design Components \nhttps://material.io/archive/guidelines/components/expansion-panels.html#\n\n[![screen](https://raw.githubusercontent.com/florent37/ExpansionPanel/master/medias/material-components-expansion-panels.png)](https://www.github.com/florent37/ExpansionPanel)\n\n\u003ca href=\"https://goo.gl/WXW8Dc\"\u003e\n  \u003cimg alt=\"Android app on Google Play\" src=\"https://developer.android.com/images/brand/en_app_rgb_wo_45.png\" /\u003e\n\u003c/a\u003e\n\n[![screen](https://raw.githubusercontent.com/florent37/ExpansionPanel/master/medias/video1.gif)](https://www.github.com/florent37/ExpansionPanel)\n\n# Download\n\n\u003ca href='https://ko-fi.com/A160LCC' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\n[ ![Download](https://api.bintray.com/packages/florent37/maven/expansionpanel/images/download.svg) ](https://bintray.com/florent37/maven/expansionpanel/_latestVersion)\n```java\ndependencies {\n    implementation 'com.github.florent37:expansionpanel:1.2.4'\n}\n```\n\n# Usage\n\n```xml\n\u003cLinearLayout\n    android:layout_height=\"wrap_content\"\n    android:layout_width=\"match_parent\"\n    android:orientation=\"vertical\"\n    \u003e\n\n    \u003ccom.github.florent37.expansionpanel.ExpansionHeader\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"match_parent\"\n        app:expansion_headerIndicator=\"@id/headerIndicator\"\n        app:expansion_layout=\"@id/expansionLayout\"\n        app:expansion_toggleOnClick=\"true\"\u003e\n\n        \u003c!-- HEADER --\u003e\n\n        ...\n        \u003c!-- HEADER INDICATOR --\u003e\n        \u003cImageView\n               android:adjustViewBounds=\"true\"\n               android:id=\"@+id/headerIndicator\"\n               android:layout_gravity=\"center_vertical|right\"\n               android:layout_height=\"wrap_content\"\n               android:layout_marginLeft=\"16dp\"\n               android:layout_width=\"wrap_content\"\n               app:srcCompat=\"@drawable/ic_expansion_header_indicator_grey_24dp\" /\u003e\n\n\n    \u003c/com.github.florent37.expansionpanel.ExpansionHeader\u003e\n\n    \u003ccom.github.florent37.expansionpanel.ExpansionLayout\n        android:id=\"@+id/expansionLayout\"\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"match_parent\"\u003e\n\n        \u003c!-- CONTENT --\u003e\n\n    \u003c/com.github.florent37.expansionpanel.ExpansionLayout\u003e\n\u003c/LinearLayout\u003e\n\n```\n\n# Header\n\n1. Connect with his Expansion Layout : `expansion_layout` (they must have the same parent)\n2. Define the indicator view with `expansion_headerIndicator` (the id of a view inside the header)\n3. If you want to expand/close when the header is clicked, setup `expansion_toggleOnClick`\n4. You can modify the indicator rotation with `expansion_headerIndicatorRotationExpanded` and `expansion_headerIndicatorRotationCollapsed`\n\n# Layout\n\nYou can modify the default expansion of the label with `app:expansion_expanded=\"false\"\n\nLayout can be toggled programmatically with `.toggle()`\n\nUse `.setEnable(true/false)` to enable/disable the expansion\n\n# Listener\n\nJust add a listener into ExpansionLayout (**not the header !**) to follow the expansion layout state\n\n```java\nExpansionLayout expansionLayout = findViewById(...);\nexpansionLayout.addListener(new ExpansionLayout.Listener() {\n    @Override\n    public void onExpansionChanged(ExpansionLayout expansionLayout, boolean expanded) {\n\n    }\n});\n```\n\n# Open only one\n\n[![screen](https://raw.githubusercontent.com/florent37/ExpansionPanel/master/medias/onlyone.gif)](https://www.github.com/florent37/ExpansionPanel)\n\nYou can setup multiple expansions layout to enable only 1 opened at time\n\n```\nfinal ExpansionLayoutCollection expansionLayoutCollection = new ExpansionLayoutCollection();\nexpansionLayoutCollection.add(ex1);\nexpansionLayoutCollection.add(ex2);\n\nexpansionLayoutCollection.openOnlyOne(true);\n```\n\nor direcly in xml with\n- ExpansionsViewGroupLinearLayout\n- ExpansionsViewGroupFrameLayout\n- ExpansionsViewGroupRelativeLayout\n- ExpansionsViewGroupConstraintLayout\n\n```\n\u003ccom.github.florent37.expansionpanel.viewgroup.ExpansionsViewGroupLinearLayout\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"\n                app:expansion_openOnlyOne=\"true\"\n                android:orientation=\"vertical\"\u003e\n\n                \u003c!-- Expansions Header \u0026 Layouts --\u003e\n\n\u003c/com.github.florent37.expansionpanel.viewgroup.ExpansionsViewGroupLinearLayout\u003e\n```\n\n# Horizontal\n\nSimply use `HorizontalExpansionLayout` instead of `ExpansionLayout`\n\n```\n\u003ccom.github.florent37.expansionpanel.HorizontalExpansionLayout\n        android:id=\"@+id/expansionLayout\"\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"match_parent\"\u003e\n\n        \u003c!-- CONTENT --\u003e\n\n\u003c/com.github.florent37.expansionpanel.HorizontalExpansionLayout\u003e\n```\n\n# RecyclerView\n\nSample: https://github.com/florent37/ExpansionPanel/blob/master/app/src/main/java/florent37/github/com/expansionpanel/ExpansionPanelSampleActivityRecycler.java\n\n```java\npublic class MyRecyclerAdapter extends RecyclerView.Adapter\u003cMyRecyclerHolder\u003e {\n\n    ...\n\n    //add an ExpansionLayoutCollection to your recycler adapter\n    private final ExpansionLayoutCollection expansionsCollection = new ExpansionLayoutCollection();\n\n\n    @Override\n    public void onBindViewHolder(MyRecyclerHolder holder, int position) {\n        //bind your elements\n\n        //just add the ExpansionLayout (with findViewById) to the expansionsCollection\n        expansionsCollection.add(holder.getExpansionLayout());\n    }\n}\n```\n\n# Single Listener\n\nUpdate gradle, add ability to have only one listener at time\n\nFor what? If you tried to debug ViewHolders with this layout, \nthen you might notice that over time addListener continues to add a listener, \nwhich causes a lot of unnecessary listeners and, moreover, \nthere can be many listeners to one layouts in different ViewHolders due to which it may cause logic breakdown\n\n```kotlin\nvar isExpanded = false\n\nexpandableLayout.run {\n    //expandableLayout.singleListener = true\n    singleListener = true\n\n    expandableLayout.addListener { expansionLayout, expanded -\u003e\n        isExpanded = expanded\n    }\n\n    //do not toggle (expand/collapse, etc) before add listener\n\n    if (isExpanded)\n        expand(false)\n    else\n        collapse(false)\n}\n```\n\n# Credits\n\nAuthor: Florent Champigny \n\nBlog : [http://www.tutos-android-france.com/](http://www.tutos-android-france.com/)\n\nFiches Plateau Moto : [https://www.fiches-plateau-moto.fr/](https://www.fiches-plateau-moto.fr/)\n\n\u003ca href=\"https://goo.gl/WXW8Dc\"\u003e\n  \u003cimg alt=\"Android app on Google Play\" src=\"https://developer.android.com/images/brand/en_app_rgb_wo_45.png\" /\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://plus.google.com/+florentchampigny\"\u003e\n  \u003cimg alt=\"Follow me on Google+\"\n       src=\"https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/gplus.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://twitter.com/florent_champ\"\u003e\n  \u003cimg alt=\"Follow me on Twitter\"\n       src=\"https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/twitter.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.linkedin.com/in/florentchampigny\"\u003e\n  \u003cimg alt=\"Follow me on LinkedIn\"\n       src=\"https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/linkedin.png\" /\u003e\n\u003c/a\u003e\n\n\nLicense\n--------\n\n    Copyright 2017 Florent37, Inc.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":["https://ko-fi.com/FlorentChampigny","https://github.com/sponsors/florent37","https://ko-fi.com/A160LCC'"],"categories":["Java"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2FExpansionPanel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorent37%2FExpansionPanel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2FExpansionPanel/lists"}