FloatingActionButton icon indicating copy to clipboard operation
FloatingActionButton copied to clipboard

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

Open IlyaEremin opened this issue 10 years ago • 2 comments

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. Я разговариваю на русском ;о

IlyaEremin avatar Jan 18 '15 18:01 IlyaEremin

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).

dirkam avatar Jan 18 '15 18:01 dirkam

@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:

IlyaEremin avatar Jan 19 '15 05:01 IlyaEremin