makovkastar / FloatingActionButton

[DEPRECATED] Android floating action button
MIT License
4.01k stars 819 forks source link

fab does not hide when attach to listview before setting scroll listener #104

Open IlyaEremin opened 9 years ago

IlyaEremin commented 9 years ago

And disable onScrollListener if attach to listview after setting scrollListener. My layout:

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.SwipeRefreshLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:id="@+id/list_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </android.support.v4.widget.SwipeRefreshLayout>

    <com.melnykov.fab.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="16dp"
        android:src="@drawable/ic_add_white"
        fab:fab_colorNormal="@color/freeme_violet"
        fab:fab_colorPressed="@color/primary_pressed"
        fab:fab_colorRipple="@color/ripple"/>

</FrameLayout>

my code:

lv.setOnScrollListener(new AutoLoadingScrollListener());
FloatingActionButton fab = findById(view, R.id.fab);
fab.attachToListView(lv);

In this case fab does not hide. If I place attachToListView before setOnScrollListener then my onScrollListener won't work.

added: I look to source code ListView and notice, that LV can has only one onScrollListener. FAB sets its own listener to listview. Now, I can't grasp how to make work 2 or more listeners for listView. Any suggestion?

P.s. Я разговариваю на русском ;о

dirkam commented 9 years ago

This seems to be similar to #99. Check that issue, I've provided a workaround that might be useful for you (require some work as you use ListView).

IlyaEremin commented 9 years ago

@dirkam yeap, it's exactly the same case and it is ok for temporary workaround. Thank a lot for link! But It looks like hack, we need more elegant solution :smiling_imp: