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.
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)
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With