【问题标题】:Visibility of expanding last view in the expandable RecyclerView在可展开的 RecyclerView 中展开最后一个视图的可见性
【发布时间】:2016-10-07 07:14:22
【问题描述】:

我希望最后一个可扩展项目中的内容在单击时完全可见,现在发生的情况意味着当我单击最后一个项目时它会向下展开,但我需要再次手动向上滚动以查看里面的内容展开的项目。最后一个可展开的项目如何完全可见。 我正在使用 Recyclerview。

【问题讨论】:

    标签: android-recyclerview expandable


    【解决方案1】:

    我找到了我想要的解决方案,我使用了

    recyclerView.smoothScrollToPosition(selectedPosition);

    设置适配器后。所以现在最后一个可展开项中的内容在单击时完全可见。

    【讨论】:

    • 如何确定 selectedPosition?它是已单击的 ParentItemIndex 吗?请提供示例
    【解决方案2】:

    只是一个补充: 如果使用h6ah4i/advrecyclerview,可以使用如下代码sn -p:

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

    【讨论】:

      猜你喜欢
      • 2019-08-17
      • 1970-01-01
      • 2011-10-15
      • 1970-01-01
      • 1970-01-01
      • 2011-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多