Visibility of expanding last view in the expandable RecyclerView

痴心易碎 提交于 2019-12-22 12:26:28

问题


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.


回答1:


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.




回答2:


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;
    }


来源:https://stackoverflow.com/questions/39911518/visibility-of-expanding-last-view-in-the-expandable-recyclerview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!