Expandable listview setselectionfromTop with animation and padding

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.

  • How to clear focus for EditText?
  • How to get screen coordinates from marker in google maps v2 android
  • “Couldn't resolve resource” in Android Studio's Preview
  • Android; fragments overlap when switching tabs
  • Detect if I am in release or debug mode in android
  • Android Circle Menu Like Catch Notes
  • 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.

    Related posts:

    Why can't MonoDroid find my assemblies?
    Updating sqlite database versions?
    How to use WebRTC + Pubnub Api for video chat client in Native android app
    Exported content providers can provide access to potentially sensitive data
    Android - ViewRootImpl$CalledFromWrongThreadException
    How to opt out from Facebook SDK event logging?
  • What should a developer know before building cellphone apps?
  • OutOfMemoryError although vm has enough free memory
  • Disable importing of Crashlytics
  • How do I display a full-width DialogFragment?
  • Android Translating To Arabic
  • Android SDK Manager Proxy Settings in LINUX
  • 3 Solutions collect form web for “Expandable listview setselectionfromTop with animation and padding”

    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);
    new Handler().postDelayed(new Runnable() {
        public void run() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    mListView.smoothScrollToPositionFromTop((int) flatpostion, HomeActivity.LIST_HEADER_HEIGHT, 200);
    }, 300);

    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)

    • You can use ListView’s setSelection(int position) method to scroll to a row.
    • You could use ListView’s smoothScrollToPosition(int position) to scroll to a particular location in the list.
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.