10

I enabled animation(expand and contract) to default android'd expandable listview using this https://github.com/idunnololz/AnimatedExpandableListView/blob/master/src/com/idunnololz/widgets/AnimatedExpandableListView.java.

However, the one limitation that I am facing is to move the current expanded click to the top.

I tried setSelectionFromTop(groupPosition, 0)

Here is the question:
- How to add animation to bringing it to the top?
- How to bring it to a top to a specific height. Lets say below 10px from the top.

Any pointers would be amazing.

Note: The solution should work from sdk 14 and above.

amalBit
  • 12,041
  • 6
  • 77
  • 94

3 Answers3

2

Any pointers would be amazing.

You can use android-advancedrecyclerview. The recycler view itself is a powerful widget that has a lot of features but for your question you can take a look at MyExpandableItemAdapter.java.

  • How to add animation to bringing it to the top?

public void scrollToPosition (int position)

public void smoothScrollToPosition (int position)

  • How to bring it to a top to a specific height. Lets say below 10px from the top.

public void scrollBy (int x, int y)

public void smoothScrollBy (int dx, int dy)

mmlooloo
  • 18,937
  • 5
  • 45
  • 64
1

This with surely work with the library you used, i tired from my own let me know you need a sample.

long packedPosition = mListView.getPackedPositionForGroup(groupPosition);

final long flatpostion = mListView.getFlatListPosition(packedPosition);



expandableListView.expandGroupWithAnimation(groupPosition);



new Handler().postDelayed(new Runnable() {

    @Override

    public void run() {

        getActivity().runOnUiThread(new Runnable() {

            @Override

            public void run() {

                mListView.smoothScrollToPositionFromTop((int) flatpostion, HomeActivity.LIST_HEADER_HEIGHT, 200);

            }

        });

    }

}, 300);
Vinay Chopra
  • 593
  • 3
  • 17
0
Kartheek
  • 7,104
  • 3
  • 30
  • 44