Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

动画不显示 #42

Open
heaofei opened this issue Jan 11, 2016 · 5 comments
Open

动画不显示 #42

heaofei opened this issue Jan 11, 2016 · 5 comments

Comments

@heaofei
Copy link

heaofei commented Jan 11, 2016

和轮播图控件一起使用没动画效果

@liaohuqiu
Copy link
Owner

可以给出更多的一些细节吗,相关的代码,布局文件。

@heaofei
Copy link
Author

heaofei commented Jan 12, 2016

https://github.com/heaofei/demo 这个是demo工程下边的轮播图是addheadview上去的有问题,大哥有时间看看吧

@brian512
Copy link

brian512 commented May 4, 2016

我遇到了同样的问题:将一个自动切换的viewpager作为header添加到GridViewWithHeaderAndFooter,但是viewpager没有切换动画。通过源码看不出哪里阻止或者中断viewpager的切换动画
补充:每一次自动切换都会调用onAttachedToWindow,相同情况下listview不会调用onAttachedToWindow

@brian512
Copy link

brian512 commented May 6, 2016

对比listview和gridview发现问题,在setupChild方法里面:
listview

        if ((recycled && !p.forceAdd) || (p.recycledHeaderFooter &&
                p.viewType == AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER)) {
            attachViewToParent(child, flowDown ? -1 : 0, p);
        } else {
            p.forceAdd = false;
            if (p.viewType == AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER) {
                p.recycledHeaderFooter = true;
            }
            addViewInLayout(child, flowDown ? -1 : 0, p, true);
        }

gridview

        if (recycled && !p.forceAdd) {
            attachViewToParent(child, where, p);
        } else {
            p.forceAdd = false;
            addViewInLayout(child, where, p, true);
        }

由于gridview中没有判断AbsListView.LayoutParams.recycledHeaderFooter,导致每次刷新header时,都会调用addViewInLayout(child, where, p, true);——>HeaderView.onAttachedToWindow

@duanhong169
Copy link

参考Android-ConvenientBanner issue: #63
可以使用RecyclerView的Grid Layout来解决切换没有动画效果的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants