Coder Social home page Coder Social logo

florent37 / expansionpanel Goto Github PK

View Code? Open in Web Editor NEW
2.0K 45.0 242.0 937 KB

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

Home Page: https://material.io/guidelines/components/expansion-panels.html

License: Apache License 2.0

Java 99.67% Shell 0.33%
android material layout expansion expansion-panels open close toggle view androidx

expansionpanel's Introduction

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.

expansionpanel's People

Contributors

elexl avatar florent37 avatar gaara87 avatar naz013 avatar owenlejeune avatar p1ng2win avatar pfieffer avatar simonmarquis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expansionpanel's Issues

Lagging/Skipping animation in large RecyclerView list

Hi,
Im using the ExpansionPanel as ItemView for my rows in a RecyclerView.
(ITem view = ImageView and text in the header --- some textviews and some buttons in the expansionLayout)

Everything works quite smooth if the recycler is smaller than 20 items.
If the size of the recycler is bigger (tested with around 70 items) it creates a heavy lagging and freezes the UI until the expanding animation is done. Unfortunately it is unusable if this behaves so slow.

If I remove the Expansion Panel and change only the visibility of the expansionView it is working very smooth. So I came to the point that not my images or the content is causing the lag but the library.

Any idea how to fix it ?

ExpansionPanel in card view causes weird layout

Hello,
First, I'd like to start by saying that you did an excellent job creating the Material Design Expansion Panel with this little guideline about it! I was really surprised that Google hasn't created an official one at first, then I found this!
Now, I've implemented it successfully in my app but my problem is that when I put it in android.support.v7.widget.CardView and I click it, the content is on top of the expansion panel. I'm not sure if you did it in another way in your example but that's what I'm trying to achieve. This is the code I used:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <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"
                android:id="@+id/expansionHeader2">

            <RelativeLayout
                    android:background="@android:color/white"
                    android:layout_height="48dp"
                    android:layout_width="match_parent"
                    android:paddingLeft="16dp"
                    android:paddingRight="16dp">

                <TextView
                        android:layout_centerVertical="true"
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="Trip name"
                        android:textColor="#3E3E3E"/>

                <TextView
                        android:layout_centerVertical="true"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="120dp"
                        android:layout_width="wrap_content"
                        android:text="Carribean cuise"
                        android:textColor="#AAA"/>

                <android.support.v7.widget.AppCompatImageView
                        android:adjustViewBounds="true"
                        android:id="@+id/headerIndicator"
                        android:layout_alignParentRight="true"
                        android:layout_centerVertical="true"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="16dp"
                        android:layout_width="wrap_content"
                        app:srcCompat="@drawable/ic_expansion_header_indicator_grey_24dp"/>

            </RelativeLayout>

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

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

            <LinearLayout
                    android:id="@+id/container"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:orientation="vertical">

                <TextView
                        android:background="#EEE"
                        android:gravity="center"
                        android:layout_height="100dp"
                        android:layout_width="match_parent"
                        android:text="content" />

            </LinearLayout>

        </com.github.florent37.expansionpanel.ExpansionLayout>
    </android.support.v7.widget.CardView>

</LinearLayout>

You can try it by yourself and I can include screenshots if needed.
Thank you!

Stuck on fragment

I add recyclerview in fragment but my app stuck in white screen (no respond)

any solutions?

Add an option to not set click listener on the header by default

I wanted to keep track of the expanded item position.
Using the default expansion listener didn't work.
So I had to write my own onClickListener which was not possible because you set it by default in the header class.
I had to create my custom header to remove the clickListener and add my own clicklistener in the recyclerview adapter.
Can you also please make it that when calling .expand() or .collapse() with false as the parameter to reset the indicator without animation too.

        if (isExpanded)
            holder.binding.expansionLayout.expand(false);
        else
            holder.binding.expansionLayout.collapse(false);
        expansionsCollection.add(holder.binding.expansionLayout);
        holder.binding.ehHeader.setActivated(isExpanded);
        holder.binding.ehHeader.setHeaderRotationCollapsed(0);
        holder.binding.ehHeader.setHeaderRotationExpanded(180);
        holder.binding.ehHeader.setOnClickListener(v -> {
            if (isEnabled){
                mExpandedPosition = isExpanded ? -1: position;
                holder.binding.expansionLayout.toggle(true);
            }
        });

RecyclerView with 2 columns issue

I'm using a GridLayoutManager with 2 columns for the RecyclerView and I'm seeing an issue where if I expand an item in the left column, the item also expands in the right column with no content. It causes a weird issue where neither item can now be collapsed.

compileOnly

com.android.support.constraint make as compileOnly

ExpansionPanel problem in recyclerview

trying to add disabled tag(TextView, added vector drawable
) to some item which has specific value, while scrolling down disabled tag moves to wrong places (i.e tag should be appear in item 1 and 3 but when i scroll recyclerview tag change its position to item no 2)

Screenshot_1577350017
22222222
Screenshot_1577350047

Last item not expandable

if no item is expand and click on last item. it expands but i have to scroll. can it works like if i click on last item and auto its expand without scroll?

init problem

java.lang.NoClassDefFoundError: Could not initialize class android.support.v7.widget.AppCompatDrawableManager
at android.support.v7.widget.AppCompatBackgroundHelper.(AppCompatBackgroundHelper.java:42)
at android.support.v7.widget.AppCompatImageView.(AppCompatImageView.java:74)
at android.support.v7.widget.AppCompatImageView.(AppCompatImageView.java:68)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:176)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:838)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:838)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:229)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:520)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:508)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:508)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:75)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:620)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:617)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:371)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:617)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:639)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:654)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:596)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:591)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)
at com.intellij.util.ui.update.MergingUpdateQueue$3.run(MergingUpdateQueue.java:271)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:286)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:244)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:352)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

openOnlyOne does not work inside a recycler view?

<com.github.florent37.expansionpanel.viewgroup.ExpansionsViewGroupConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:expansion_openOnlyOne="true"
            app:layout_constraintTop_toBottomOf="@id/tv_reservations_title"
            app:layout_constraintLeft_toRightOf="parent">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerViewForTimelineContent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:overScrollMode="never"
                /> <!--ifContentScrolls-->
            
        </com.github.florent37.expansionpanel.viewgroup.ExpansionsViewGroupConstraintLayout>

The RecyclerView item has expansion headers and expansion layouts.

Am I missing something here?
The expansion header and layouts have to be dynamically placed in my case, hence the Recycler View. Does the library support expansion_openOnlyOne for the headers and layout populated dynamically?

Thanks

notifyDataSetChanged collapses all expanded views

Possible causes is that onAttachedToWindow is called with isExpanded being always false. Any suggestions for a fix?
I've also tried just doing notifyItemChanged for one row: It collapses it the first time but then seems to work if I call it again.

A small mistake in "Usage" Description

Hi , in the part of "Usage" headerIndicator and expansionLayout ID is defined:
app:expansion_headerIndicator="@id/headerIndicator"
app:expansion_layout="@id/expansionLayout"

That should be:
app:expansion_headerIndicator="@+id/headerIndicator"
app:expansion_layout="@+id/expansionLayout"

Views height inside ExpansionLayout

With this layout from the sample, ExpansionLayout works as expected and the TextView height is 100dp :

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

            <LinearLayout
                android:id="@+id/container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:background="@color/md_red_500"
                    android:gravity="center"
                    android:text="content"/>

            </LinearLayout>

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

On the contrary, with the following layout (without le linearLayout) the height seems to be WRAP_CONTENT and not 100dp :

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

            <TextView
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:background="@color/md_red_500"
                android:gravity="center"
                android:text="content"/>
            
        </com.github.florent37.expansionpanel.ExpansionLayout>

Manifest error After add to project

when i add dependency and use expanision panel in my project i have got this error in manifest:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:6:5-27:19 to override.

Expandblelayout won`t take as much place as it should take

Hi,
I`m trying to use Expandblelayout but whenever I click on the header the view inside the Expandblelayout wont show fully, although it has the required space on screen.(most view has wrap content value in the layour height attribute)

Can anyone help?

onToggleListner()

Hi @florent37 ,

Quick question, using java is there the function of a toggle event from code behind? (aiming to then load content when toggled)
Thanks in advance.

Header indicator not drawn when bound to ExpansionHeader

I'm using an ImageView with a VectorDrawable; when expansion_headerIndicator attribute is not set, the image is shown, but whet it's set to the ImageView's id, the image is not shown anymore. I have minSdk=21, tried on Android 8.0.

<com.github.florent37.expansionpanel.ExpansionHeader
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:expansion_layout="@id/content"
                app:expansion_headerIndicator="@id/ivPanelIndicator"
                app:expansion_toggleOnClick="true">
    <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            tools:text="Text" />

        <ImageView
            android:id="@+id/ivPanelIndicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scaleType="center"
            android:adjustViewBounds="true
            android:src="@drawable/ic_keyboard_arrow_down_24dp" />
    </LinearLayout>
</com.github.florent37.expansionpanel.ExpansionHeader>

Continuous update

When the expansion layout is open, the screen updates without stopping

Change icon when expanded and collapsed

would like to request a new feature about changing icon when expanded and collapsed.
This project ("com.github.ivbaranov.mfb.MaterialFavoriteButton" google this) already have above functionality.

toggle() does not work

Hi I'm trying to toggle the layout from code, but it does not work.

Calling toggle() (not expanding):
immagine

Pressing on the header (and works fine):
immagine2

My code:

public void addDynamicLayout(int count_p, String[] param) {
        final String nome = "PROGRAMMA " + String.valueOf(count_p);
        final ExpansionHeader expansionHeader = createExpansionHeader(count_p, nome);
        dynamicLayoutContainer.addView(expansionHeader, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        final ExpansionLayout expansionLayout = createExpansionLayout(count_p, param);
        dynamicLayoutContainer.addView(expansionLayout, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        expansionLayout.addListener(new ExpansionLayout.Listener() {
            @Override
            public void onExpansionChanged(ExpansionLayout expansionLayout, boolean expanded) {
                editorProg.putBoolean(nome, expansionHeader.isExpanded());
                editorProg.commit();
            }
        });

        boolean toggle = toggleProg.getBoolean(nome, false);

        if (toggle) {
            expansionLayout.toggle(true);
        }

        expansionHeader.setExpansionLayout(expansionLayout);
    }

Thanks in advance.

Feedback ExpansionPanel Problem

Hello, thankyou your library, In RecyclerView activity have a problem, when i opne item1, and than i scroll item, the other item also will open.

problem with expansion panel in recyclerview

I was trying to use expansion panel in recyclerview, and done with getting result from api but if result having 7 or 8 items its showing perfectly but list having 50 and more item then its getting more time and showing black screen also doesn't showing list after taking more time to build.
layout design in below image, please check this

Screenshot

Unable to resolve dependency

The current documentation shows to include the below dependency:
compile 'com.github.florent37:expansionpanel:1.2.0'

Gradle Sync fails on using this dependency.

Expansion after init does not work

Hello, thank you for the library.

I stumbled on a bug while using the expansion panel in a recycler view.
I need to handle the expansion manually, so I'm using collapse(boolean animated) and expand(boolean animated) to update the expansion layout accordingly.

It works fine, except when initializing the layout state to expanded. The layout is not expanded by default (in the XML) but set to expanded (expand(false)) by the adapter when the activity starts.

I think the cause is:

If that's the case, I think updating the preDraw callback to

//now we have a size
if (expanded) {
    setHeight(getChildAt(0).getHeight());
}

might be the fix. I can do a PR for this if you want.

The same problem seem to be present in the horizontal version, though I haven't tested it.

Gradle Syn Failed

Try to implement your library to one my project, but gradle syn failed & please update your readme file too. For easy to implement.

Header Indicator doesn't appear on right

Hi there,

I'm trying to use this library, but I've found that using your demo code in the README, the header indicator refuses to display on the right side of the panel. For example, I have this code:

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

    <com.github.florent37.expansionpanel.ExpansionHeader
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:expansion_headerIndicator="@id/description_indicator"
        app:expansion_headerIndicatorRotationCollapsed="270"
        app:expansion_headerIndicatorRotationExpanded="0"
        app:expansion_layout="@id/description_layout">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Test Test Test" />

        <ImageView
            android:id="@+id/description_indicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="16dp"
            android:layout_marginStart="16dp"
            app:srcCompat="@drawable/ic_expand" />

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

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

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Blah blah blah" />

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

</LinearLayout>

which produces this result:

studio64_2018-02-27_12-45-35

I was able to resolve the issue by replacing the layout_alignParentRight/End attributes with a android:layout_gravity="end" on the indicator, but is this the right solution? If so, the README should probably be updated to reflect this.

problem with the expansion layout height

Hello

I am using your library with a personnal project of mine but the problem is that the expansion layout does not take the full height of the content but instead use a height of his own , i have specified that the height of my content is 74 dp but the expansion layout does not even show 20 dp of it ? what am i doing wrong ?

Thank you for your help in advance :)

`

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

        <!-- HEADER -->

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@color/black_3f3f3f">

            <LinearLayout
                android:id="@+id/line_top_header"
                android:layout_width="match_parent"
                android:layout_height="36dp"
                android:background="@drawable/line_menu_deroulant_background">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="17dp"
                    android:fontFamily="@font/font_bold"
                    android:gravity="center_vertical"
                    android:text="@string/line_consommation_voix"
                    android:textColor="@color/line_menu_deroulant_titre_color_c33f90"
                    android:textSize="12sp" />
            </LinearLayout>

            <ImageView
                android:layout_width="17dp"
                android:layout_height="15dp"
                android:layout_below="@id/line_top_header"
                android:layout_marginTop="@dimen/line_menu_deroulant_triangle_margin"
                android:elevation="2dp"
                android:rotation="180"
                android:src="@drawable/line_menu_deroulant_triangle"
                android:visibility="gone" />

        </RelativeLayout>
        <!-- HEADER INDICATOR -->
        <android.support.v7.widget.AppCompatImageView
            android:id="@+id/headerIndicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|right"
            android:layout_marginRight="16dp"
            android:adjustViewBounds="true"
            app:srcCompat="@drawable/vecteur_expansion_layout_gris" />


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

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

        <!-- CONTENT -->

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/line_menu_deroulant_ouvert_color_f8f8f8"
            android:orientation="horizontal"
            android:weightSum="2">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="76dp"
                android:layout_weight="1"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_marginLeft="17dp"
                    android:layout_marginTop="17dp"
                    android:background="@drawable/icn_line_national_call" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="15dp"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/myfont"
                        android:text="@string/line_solde"
                        android:textColor="@color/line_solde_color_565656"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/myfont"
                        android:text="@string/line_voix_national"
                        android:textColor="@color/line_voix_national_color_842c63"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/myfont"
                        android:text="@string/line_duree_sample"
                        android:textColor="@color/line_voix_national_color_842c63"
                        android:textSize="24sp" />
                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="17dp"
                    android:background="@drawable/icn_line_international_call" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="15dp"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/myfont"
                        android:text="@string/line_solde"
                        android:textColor="@color/line_solde_color_565656"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/myfont"
                        android:text="@string/line_voix_international"
                        android:textColor="@color/line_voix_national_color_842c63"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:fontFamily="@font/myfont"
                        android:text="@string/line_duree_sample"
                        android:textColor="@color/line_voix_national_color_842c63"
                        android:textSize="24sp" />
                </LinearLayout>

            </LinearLayout>
        </LinearLayout>

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

`

Expand upward

As of now the view expands downward. Is there possibility to expand in upward?

Compile error

Program type already present: com.github.florent37.expansionpanel.R$dimen
Message{kind=ERROR, text=Program type already present: com.github.florent37.expansionpanel.R$dimen, sources=[Unknown source file], tool name=Optional.of(D8)}

Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:...\app\build\intermediates\transforms\instantRunSlicer\debug\1

Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.

Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete

Caused by: com.android.tools.r8.utils.AbortException

NestedScrollView isn't scolling when start scrolling on ExpansionHeader (the scroll event isn't triggered)

Hi,

i have a problem with Scrolling behavior of the activity when added 3 ExpansionPanels in vertical Linearlayout. since they are next to each others(in a row), they occupy a big space.

My activity is androidx.coordinatorlayout.widget.CoordinatorLayout with a androidx.core.widget.NestedScrollView
reference: https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout

The problem persist when start scrolling from the ExpansionHeader. It never scroll!

But it is scrolling when starting outside of the ExpansionPanel's Headers

By the way, i have an AppCompatAutoCompleteTextView in 2 ExpansionLayouts of the activity.

Each one of them is having a dropdown menu as described in the Material Guidelines:
link: https://material.io/develop/android/components/menu/#exposed-dropdown-menus

Here it is:

<com.google.android.material.textfield.TextInputLayout
	style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
	android:layout_width="0sp"
	android:layout_height="wrap_content"
	android:layout_weight="1"
	app:boxStrokeWidth="2dp"
	android:hint="">

	<androidx.appcompat.widget.AppCompatAutoCompleteTextView
		android:id="@+id/exposed_dropdown"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:editable="false"
		tools:ignore="Deprecated" />

</com.google.android.material.textfield.TextInputLayout>

ExpansionLayout is not resizing well

I have 2 ExpansionPanels set vertically.

<ExpansionsViewGroupLinearLayout>

  <ExpansionHeader />
  <ExpansionLayout />

  <ExpansionHeader />
  <ExpansionLayout />

</ExpansionsViewGroupLinearLayout>

The ExpansionLayout height is bigger than the first.

I don't know if the behavior is linked to the ScrollView but after the first toggle the sizes of the ExpansionLayout are reduced even if the ExpansionLayout height is set to wrap_content

Is there something to do to force the ExpansionLayout to take the full height of all its chidren ?

Gradle sync fails using 1.2.0

If I try to use version 1.2.0, gradle sync fails every time.

Downgrading to 1.1.1 get's it working again.

Unfortunately Android Studio is not telling me what the problem is at all.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.