0

I am working on a search which has a listview And at the bottom and I want that list View To hide when the scrolled up and view again when scrolled down and it would be good if it is animated and as I am using the same layout for multiple activities. I would prefer to make changes in the XML file. pl refer the screen shot screen Shot

qwertygamer
  • 130
  • 8

2 Answers2

0

I think this answer basically answers that question. Haven't tested it but logically it works. In the /* do something */ area for the listView.setOnDetectScrollListener(new OnDetectScrollListener() just change the visibility of the search layout.

The link to the forum is here.

Community
  • 1
  • 1
0

@qwertgamer so for the animation you need a few things,

  1. A XML file in an anim Folder inside your res Folder and call the file something like search_animation.xml.

  2. Mess around with this code a bit but this is the general concept of what you want to do with it:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:fromYDelta="0%" android:toYDelta="-100%" android:duration="600"/>
</set>
  1. For the scrolling events you need to create an Animation by doing something like this
Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.animation);
        anim.setInterpolator((new AccelerateDecelerateInterpolator()));
        anim.setFillAfter(true);
        YOUR_SEARCH_FRAME.setAnimation(anim);
        anim.start();
Ziad Akiki
  • 2,601
  • 2
  • 26
  • 41
  • ALSO, have another animation.xml file that animated from off the screen -> to the screen and basically switch the values of the 'android:fromYDelta' and 'android:toYDelta' values – BrendanOswego Dec 14 '16 at 09:05
  • I tried what u gave me the hiding part worked perfectly but the animation got messed up. It's supposed to animate from its layout to the hide inside the Activity bar but it starts from the middle of the listView and ends at its own layout. @BrendanOswego – qwertygamer Dec 14 '16 at 13:14
  • Thanks... For the Help, i resolved the issue With the Default animation search.animate().translationY(search.getHeight()); – qwertygamer Dec 19 '16 at 07:51