[Android Open Source][ListView] FlabbyListView

2015. 7. 29. 15:05Programing/Android Open Source

https://github.com/jpardogo/FlabbyListView


Android library to display a ListView which cells are not rigid but flabby and react to ListView scroll and touch events.

A video example of this library is on this youtube video.
The demo app can be found on the play store.
And I also wrote a blog post about this library in my blog

 

Usage

1.Place the FlabbyListView on your layout:

    <com.jpardogo.android.flabbylistview.lib.FlabbyListView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

2.Populate it with items which xml layout is wrap by a FlabbyLayout:

    <!--Notice that this view extends from <FrameLayout/>.-->
    <com.jpardogo.android.flabbylistview.lib.FlabbyLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/apk/tools"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="vertical">

        <!--Your content-->

    </FlabbyLayout>

3.Set the color of each item. It needs to be set on the getView method of your adapter callingsetFlabbyColor from FlabbyLayout:

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_list, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        int color = Color.argb(255, mRandomizer.nextInt(256), mRandomizer.nextInt(256), mRandomizer.nextInt(256));
        ((FlabbyLayout)convertView).setFlabbyColor(color);
        holder.text.setText(getItem(position));
        return convertView;
    }

Including in your project

You can either add the library to your application as a library project or add the following dependency to your build.gradle:

Maven Central

dependencies {
    compile 'com.jpardogo.flabbylistview:library:(latest version)'
}

Notes

The iOS version developed by brocoo is available at BRFlabbyTable