Instead of a fab, I put an image, and I want this image to disappear at the end of the list as a fab. Even better, it works like in ScrollAwareFABBehavior with animation R.anim.design_fab_out and R.anim.design_fab_in

 <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:fitsSystemWindows="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/lv_news" android:dividerHeight="3dp" android:layout_gravity="center_horizontal" android:layout_below="@+id/linearLayout" /> </LinearLayout> <ImageView android:id="@+id/fab" android:layout_width="60dp" android:layout_height="60dp" android:layout_gravity="bottom|right" android:layout_marginBottom="20dp" android:layout_marginRight="20dp" /> </android.support.design.widget.CoordinatorLayout > 

    2 answers 2

    Maybe someone decided to come in handy

      ListView listview; ImageView fab; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_news); fab = (ImageView) findViewById(R.id.fab); listview = (ListView) findViewById(R.id.lv_news); listview.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE && (listview.getLastVisiblePosition() - listview.getHeaderViewsCount() - listview.getFooterViewsCount()) >= (adapter.getCount() - 1)) { animFab(0); } else animFab(1); } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); } private void animFab(final float scale) { ViewCompat.animate(fab) .setInterpolator(AnimUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR) .scaleX(scale) .scaleY(scale) .withStartAction(new Runnable() { @Override public void run() { if (scale == 1) fab.setVisibility(View.VISIBLE); } }) .withEndAction(new Runnable() { @Override public void run() { if (scale == 0) fab.setVisibility(View.GONE); } }) .setDuration(250) .withLayer() .start(); } 

    Animutils.java

     public class AnimUtils { public static final FastOutLinearInInterpolator FAST_OUT_LINEAR_IN_INTERPOLATOR = new FastOutLinearInInterpolator(); } 
      1. Hang scroll listener on ListView

      2. In it, track the moment you scroll the list to the bottom.

      3. Apply animation and fade to your picture.

      • You can write how to do it - Artem
      • @ Artem, so I already wrote ... - YuriySPb
      • Your answer is probably the most obvious, I’ve been digging in this direction for so long. - Artem
      • @Artem, and what did you dig? Judging by the question, you just replaced FAB with imageView - YuriySPb
      • one
        Yes, I'm sorry most likely my fault, next time I will ask questions more specifically. I needed an example of solving my problem, but not advice on what I should use - Artem