Giter Club home page Giter Club logo

expandablelayout's Introduction

ExpandableLayout

ExpandableLayout

ExpandableLayout provides an easy way to create a view called header with an expandable view. Both view are external layout to allow a maximum of customization. You can find a sample that how to use an ExpandableLayout to your layout.

ExpandableLayout GIF

Integration

The lib is available on Maven Central, you can find it with Gradle, please

dependencies {
    compile 'com.github.traex.expandablelayout:library:1.2.2'
}

Usage

ExpandableLayout

Declare an ExpandableLayout inside your XML layout file. You also need to other layouts for header and content:

  <com.andexert.expandablelayout.library.ExpandableLayout
         android:id="@+id/expandableLayout"
         xmlns:expandable="http://schemas.android.com/apk/res-auto"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         expandable:headerLayout="@layout/view_header"
         expandable:contentLayout="@layout/view_content"/>
         

ExpandableLayoutItem && ExpandableLayoutItem

You can use ExapandableLayout in an ExpandableLayoutListView with ExpandableLayoutItem as row :

ExpandableLayoutItem

  <com.andexert.expandablelayout.library.ExpandableLayoutItem
         android:id="@+id/expandableLayout"
         xmlns:expandable="http://schemas.android.com/apk/res-auto"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         expandable:headerLayout="@layout/view_header"
         expandable:contentLayout="@layout/view_content"/>
         

ExpandableLayoutListView

  <com.andexert.expandablelayout.library.ExpandableLayoutListView
         android:id="@+id/expandableLayout"
         xmlns:expandable="http://schemas.android.com/apk/res-auto"
         android:layout_width="match_parent"
         android:layout_height="match_parent"/>
         

If you want to manage the OnScroll, you have to use OnExpandableLayoutScrollListener and don't forget to call super in each method.

You can call dynamically open, close and isOpened from an ExpandableLayout object.

Customization

You can change duration of the animation:

  • app:duration [integer def:200] --> Duration of the animation

Troubleshooting

If you want to use the ExpandableLayoutListView with EditText, you have to set android:windowSoftInputMode="adjustPan" to prevent the ListView to redraw itself and close the ExpandableLayoutItem.

Acknowledgements

Thanks to Google for its ExpandableListview :)

MIT License

    The MIT License (MIT)
    
    Copyright (c) 2014 Robin Chutaux
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.

expandablelayout's People

Contributors

dinosoeren avatar traex 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expandablelayout's Issues

'@layout' isn't locating resources in the XML implementation of the ExpandableLayout

When I try and build the grade I get these errors, both of the same kind, in the XML:

Error:(16) No resource identifier found for attribute 'headerLayout' in package 'com.example.heavymagikhq.expandablelayoutlibrary'

Error:(16) No resource identifier found for attribute 'contentLayout' in package 'com.example.heavymagikhq.expandablelayoutlibrary'

Both indicate the '@layout' function isn't working in this XML code:

 <com.andexert.expandablelayout.library.ExpandableLayout
        android:id="@+id/first"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        expandable:headerLayout="@layout/view_header"   ------- > Not working 
        expandable:contentLayout="@layout/view_content" ------- > not working
        android:background="#e74c3c"/>

Does anyone know how to fix this?

Thanks.

NullPointerException after Add Footer ExpandableLayoutListView

I have try the example of ExpandableLayout by add footer to listview but after I scroll to the end of list

02-06 16:16:47.505: E/AndroidRuntime(25942): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Boolean com.andexert.expandablelayout.library.ExpandableLayoutItem.isOpened()' on a null object reference.

Is there any possible way to footer to ExpandableLayout

Expanding animation problem.

Using the sample, I changed the EditText to a TextView, and put a long text in it ( 7-8 rows ).
The animation doesn't work smoothly, the view expands until a certain point, then "jumps" to full width instantly.

Multiple Children?

Does this library support multiple children in the expand? I'm assuming not since the ExpandableLayoutListView doesn't use an BaseExpandableListAdapter as it's adapter.

java.lang.IllegalArgumentException: HeaderLayout and ContentLayout cannot be null!

java.lang.IllegalArgumentException: HeaderLayout and ContentLayout cannot be null!

I have tried everything. Even copying the whole code.

        <com.andexert.expandablelayout.library.ExpandableLayout
            android:id="@+id/expandableGraph"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            expandable:el_headerLayout="@layout/view_header"
            expandable:el_contentLayout="@layout/view_content"
            android:background="#e74c3c"/>

Can't inflate ExpandableLayout

You seem to have changed the RelativeLayout to a FrameLayout in the in ExpandableLayout:

https://github.com/traex/ExpandableLayout/blob/master/library/src/main/java/com/andexert/expandablelayout/library/ExpandableLayout.java#L65-L70

But you haven't changed the RelativeLayouts in the actual layout file you are inflating, this is causing issues with inflating a layout containing ExpandableLayout.

https://github.com/traex/ExpandableLayout/blob/master/library/src/main/res/layout/view_expandable.xml

When expandable:el_contentLayout View is a ListView, it seems not working

Thanks for your project.
I have some problem when using your project.
I am trying to add a ListView as the expandable View.
And When I add list item to the ListView, the expandable view layout height can not grow when i add new list item to this ListView.
Am I doing something wrong?
Thanks Very Much.

java.lang.NullPointerException

java.lang.NullPointerException
at com.andexert.expandablelayout.library.ExpandableLayoutListView.performItemClick(ExpandableLayoutListView.java:65)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)

if you add more items,for example,ten or twenty so that listview will hide some items,the bug will reappear.

ExpandableLayoutItem expandableLayout = (ExpandableLayoutItem) getChildAt(position).findViewWithTag(ExpandableLayoutItem.class.getName());
if (expandableLayout.isOpened()) {
    expandableLayout.hide();
} else {
expandableLayout.show();
}

outdated compile instructions

The compile instrucions in the instructions reads:

compile 'com.github.traex.expandablelayout:library:1.2.2'

in Android Studio 1.3 i was not able to sync gradle files without adding the latest 1.3 line:

compile 'com.github.traex.expandablelayout:library:1.3'

update example

The current example has the same child views for every expansion. To show the full use case of this library, I'd suggest having different content for each expansion.

Rendering problems

Hi, first thanks for this library and second I have a rendering problems... My min sdk version is 14 and my code in xml:

<com.andexert.expandablelayout.library.ExpandableLayout
android:id="@+id/first"
xmlns:expandable="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
expandable:el_headerLayout="@layout/threads_header"
expandable:el_contentLayout="@layout/thread_content"
android:background="#FF2B343F"
android:layout_below="@+id/rResume"
android:layout_marginTop="5dp"/>

And now you can see my error:
screenshot 1

Thanks in advance!

Gradle Build Failed

Hi,

when I add your dependency in .gradle file, I get following error:

Attribute application@icon value=(@drawable/ic_silent_hill) from AndroidManifest.xml:30:9
is also present at com.github.traex.expandablelayout:library:1.2.2:13:9 value=(@drawable/ic_launcher)
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:27:5 to override

I tried tools:replace="android:icon" and nothing happens, and it still gives the same error.

Content layout does not match expandable layout width

Header layout using relative layout with layout_width="match_parent" is viewed just fine, match with expandable layout. But, I am using linear layout with layout_width="match_parent" in content layout and it does not match parent, rather it is wrapped.
Do I have to use relative layout to match it with parent or is there other solution?

Regards,
anas

btw, great codes. Thank you, i am using the library for my project :D

setLayoutAnimationListener() Will Not Work

You are applying the supplied AnimationListener to animation. However, you replace animation on every expand() and collapse() call, and the new Animation does not have the listener. Either don't keep replacing animation, or hold onto the AnimationListener and apply it to each new Animation that you create.

ExpandableLayout with empty headerLayout ?

Hi there,

I needed an ExpandableLayout which is triggered by an CheckBox and NOT by its header.

So I am searching for the smallest header.

Leaving the field empty or setting it to @null won't work.

This is my smallest "almost invisible" header:

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

    <View
        android:layout_width="1px"
        android:layout_height="1px"/>

</RelativeLayout>

I'd like this to be fixed...

Greetings,
DaRolla

ExpandableLayoutRecyclerView is ready ???

First,thanks for your great job...i like this widget...
RecyclerView is publish and release now...
So.............
1.Can you compact it?Maybe you can call it ExpandableLayoutRecyclerView ๐Ÿ‘
2.I have ExpandableLayout in my RecyclerView and i want to know which expandableLayout is open state,then i can close it via code...So,can you make a callback when the expandableLayout clicked...
Waitting for your update...
Ps.Sorry for my poor english...

transformation in feature

is that possible to add custom transformation or preset enum for applying the custom interpolation in all the classes?

ExpandableLayoutListView

Can't see the last item auto open the back view in ExpandableLayoutListView , instead , you need to scroll the ExpandableLayoutListView to see the back view.

Bug? contentLayout never full width if orientation = vertical

Generally it works fine but something is behaving very strange. I have this expandable list:

<com.andexert.expandablelayout.library.ExpandableLayout
            android:id="@+id/socialmediaLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/md_material_blue_600"
            app:el_contentLayout="@layout/layout_socialmedia_body"
            app:el_duration="400"
            app:el_headerLayout="@layout/layout_socialmedia_header" />

and this is the layout of "layout_socialmedia_body":

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

    <EditText
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:gravity="center"
        android:hint="Hello World !"
        android:textColor="@android:color/white"
        android:background="#c0392b"/>

    <Button
        android:layout_below="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="click ME !"/>

</LinearLayout>

When I now tap on the header to expand the list, the body layout displays but only uses about 30% of the screen width, even though I defined it with "match_parent".
It only seems to happen if I define the LinearLayout orientation to "vertical", if I define it "horizontal" the view actually uses the full width of the screen.
Also if I change LinearLayout to RelativeLayout it also uses the full width of the screen. The only time it doesn't work is if I use LinearLayout together with orientation "vertcal".

I assume this is a bug? Please fix, thank you :)

Attribute "headerLayout" has already been defined

...app/build/intermediates/exploded-aar/com.viewpagerindicator/library/2.4.1/res/values/values.xml
Attribute "headerLayout" has already been defined

How to overcome this. I think another library also has "headerLayout" attribute

Implement in menu.xml

I just wondering, how to implement in menu.xml. I would like to add ripple effect on setting icon i.e. if possible. Thanks in advance!

Project refresh failed

Hi
upon importing your project into Android Studio, I get the following error:

Error:No such property: POM_ARTIFACT_ID for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer

Please advise

MultiLevel

Can we have multi level in this Expandable ListView??
expecting +ve response...

android 6.0 report exception

03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: FATAL EXCEPTION: main
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: Process: com.ape.smartleftpage, PID: 8416
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: java.lang.IllegalStateException: Underflow in restore - more restores than saves
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.graphics.Canvas.native_restore(Native Method)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.graphics.Canvas.restore(Canvas.java:540)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at com.andexert.library.RippleView.draw(RippleView.java:164)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15388)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15339)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15339)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15339)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15339)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15339)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15339)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3719)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3699)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:15339)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:286)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:292)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:327)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewRootImpl.draw(ViewRootImpl.java:3015)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2819)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2431)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1321)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6703)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:894)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:696)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:631)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:880)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:815)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:104)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:207)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5683)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
03-11 09:24:00.386 8416-8416/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

is there any way to implement expandable indicator (groupIndicator) ?

This is awesome library but is there any way to use android:groupIndicator="@drawable/settings_selector" like expandablelistview in ExpandableLayout header?

get

or any onclick , on expand collapse listener available such that we can animate the vectordrawables or images like new material drawer in ExpandableLayout header!

Error on dependency

Hey guys!

I want to use com.github.traex.expandablelayout:library:1.2.2 and the new compile 'com.android.support:design:22.2.0'

but when I use I get the error: Error:(1) Attribute "headerLayout" has already been defined

I find and I found the same attr: int attr headerLayout 0x?????

There are some resolution for this?

thanks, Raul

Footer doesn't work with it's own onClickListener

Before I use this library, it worked fine with footer having own OnClickListener.

I assume this occurs when I attach this library. I didn't do any other things.

Debugger saids

java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1(I tested with size 1 listview).

I'm now using listClickListener instead. But it's Little confusing.

hope this issue fixes very soon.

Auto expand

How to expand the specified item automatically after created?

Inner Content & Listeners

How can i add listener for Expand & Collapse Listener for Listview.??
How can i access inner content view & it's click listener in activity..?
Expecting +ve & quick response...

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.