Skip to content

yang4boy/ExpandableHeightListView

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpandableHeightListView

Android Library to put a ListView inside a ScrollView without collapsing.

Maven Central Android Arsenal

How to use

Add this to your build.gradle:

repositories {
    mavenCentral()
}

dependencies {
  compile 'com.github.paolorotolo:expandableheightlistview:1.0.0'
}

Add ExpandableHeightListView instead of ListView in your xml files:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <com.github.paolorotolo.expandableheightlistview.ExpandableHeightListView
            android:id="@+id/expandable_listview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="8dp">
        </com.github.paolorotolo.expandableheightlistview.ExpandableHeightListView>
</ScrollView>

Expand ExpandableHeightListView programmatically:

    ExpandableHeightListView expandableListView = (ExpandableHeightListView) findViewById(R.id.expandable_listview);
    
    expandableListView.setAdapter(adapterName);

    // This actually does the magic
    expandableListView.setExpanded(true);

It also works well with GridView.

Just use this instead:

<com.github.paolorotolo.expandableheightlistview.ExpandableHeightGridView
            android:id="@+id/expandable_listview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="8dp">
        </com.github.paolorotolo.expandableheightlistview.ExpandableHeightGridView>

Example

See it in action: download test .apk here.

Also check the example app's sources here on GitHub (ExpandableHeightListViewExample).

##Wait, what? Well, did you ever try to put a ListView inside a ScrollView?

This is what happens.

And this is what you can do with ExpandableHeightListView.

Inspired by this answer on StackOverflow.

About

Expandable Height ListView for Android

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%