huxq17 / XRefreshView

一个万能的android下拉上拉刷新的框架,完美支持recyclerview
1.7k stars 501 forks source link

StickListiew 头部置顶问题。 #103

Closed trycatchx closed 6 years ago

trycatchx commented 7 years ago

使用StickHeadListiew, 我在上拉的时候。stickHead 不能依旧 置顶于顶部。而是整个 StickHeadListiew 向上移动。上啦加载完毕之后会恢复原状。有没有办法让上拉StickHeadListiew 的时候 stickHead 还是置于顶部不变?

trycatchx commented 7 years ago

目前解决一个StickHeadListview 上拉加载更多会 回跳的问题:

 private void scrollback(int offset) {
        View child = mContentView.getContentView();
        if (child instanceof AbsListView) {
 ..
        } else if (child instanceof RecyclerView) {
    ..
        } else {
            try {
                if (Class.forName("se.emilsjolander.stickylistheaders.StickyListHeadersListView").isInstance(child)) {
                    Class clazz = child.getClass();
                    Method m1 = clazz.getDeclaredMethod("getWrappedList");
                    ListView listView = (ListView) m1.invoke(child);
                    if (listView != null) {
                        listView.smoothScrollBy(offset, 0);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }

暂时用反射机制 去解决!因为没有把stickheadList 移入到 到XfreshView