ViewPager片段里面有边距和页面变压器不能正确渲染 [英] ViewPager inside Fragment with margins and page transformer not rendering correctly

查看:1116
本文介绍了ViewPager片段里面有边距和页面变压器不能正确渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有里面的片段一个viewpager。

I have a viewpager with fragments inside it.

我使用类似于例如在code。

I use the code similar to e.g.

<一个href=\"http://stackoverflow.com/questions/19159243/viewpager-margin-in-pagetransformer-transformations\">ViewPager利润率PageTransformer转换

和填充,所以你可以看到在片段的两侧正在查看片段的淡出边缘。

and padding so you can see the faded out edge of fragments on either side of the fragment you are currently viewing.

但问题是当viewpager第一次启动时,两边的片段不褪色和缩小。

But the problem is when the viewpager is first started, the fragments on either side are not faded and zoomed out.

即。我ZoomOutPageTransformer的transformPage方法不会被调用,直到你开始刷卡,所以最初的关闭页的左/右或任何观点看问题,然后再跳来寻找合适的一次刷卡完成。

I.e. the transformPage method of my ZoomOutPageTransformer doesn't get called until you start swiping, so the initial off-page right / left or wherever views look wrong, and then 'jump' to looking right once a swipe is done.

任何想法如何,我可以导致它正确地呈现,所以如如果我叫

Any ideas how I can cause it to render correctly, so e.g. if I call

myViewPager.setCurrentItem(1) - 或任何东西,这些页面向两边将被适当缩小

myViewPager.setCurrentItem(1) - or anything, the pages to the sides will be appropriately zoomed out.

我怎样才能获得viewpager与应用到戏外片段zoomoutpagetransformer正确的OnCreate呈现?

How can I get the viewpager to render correctly oncreate with the zoomoutpagetransformer applied to the 'off screen' fragments?

推荐答案

我知道我来不及回答,但我面临着同样的问题,并没有找到任何答案。因此,对于任何人谁面临着同样的问题,这里是什么:

I know I'm too late to answer, but I faced the same issue and did not find any answer to this. So for anyone who faces the same issue, here is something:

所以基本上页变压器不能正确号召的下一个项目时,它加载的第一次,虽然它滚动,第一次的时候效果很好。

So basically the page transformer does not get correctly called for the next item when it loads the first time, though it works well when scrolled for the first time.

所以我写了几行滚动页面一点,拿回来它得到我们所需的视图:

So I wrote a few lines to scroll the page a little and get it back which gets us the required view:

 viewPager.scrollBy(5,0);
 viewPager.scrollBy(-5,0);

这篇关于ViewPager片段里面有边距和页面变压器不能正确渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆