2

enter image description here

I want the things in the last expandable item to be fully visible when it is clicked,Now what is happening means when I click on last item it expands down, but I manually need to scroll up again to see the the things inside the expanded item.How can the last expandable item be fully visible. I am using Recyclerview.

Cheticamp
  • 61,413
  • 10
  • 78
  • 131
Vineeth Holla
  • 841
  • 7
  • 11

2 Answers2

3

I have found the solution which I wanted, I used

recyclerView.smoothScrollToPosition(selectedPosition);

after setting the adapter. So now the things in the last expandable item is fully visible when it is clicked.

Panther
  • 3,312
  • 9
  • 27
  • 50
Vineeth Holla
  • 841
  • 7
  • 11
0

Just a supplementary: If you use h6ah4i/advrecyclerview, you can use the following code snippet:

    @Override
    public boolean onHookGroupExpand(int groupPosition, boolean fromUser) {
        // NOTE21: collapse all other groups when one item expand.
        mExpMgr.collapseAll();

        // NOTE21: Visibility of expanding last view in the expandable recyclerview
        if (groupPosition == getGroupCount() - 1) {
            mRecyclerView.smoothScrollToPosition(groupPosition + getChildCount(groupPosition));
        }
        return true;
    }
Weiyi
  • 1,843
  • 2
  • 22
  • 34