安卓ViewPager定制 [英] android ViewPager customizable

查看:214
本文介绍了安卓ViewPager定制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现滚动视图如下所示:

I need to implement a scroll view as shown:

也就是说,在闲置状态的图像1是全尺寸和图像2看得见的可见部分(从而使一个线索,他可以滚动内容的用户)。滚动双击自动滚屏观点不能停留在中间状态和滚动后,必须完成(iOS版一样的滚动浏览时不会寻呼已启用已开启):

That is, in "idle" state image "1" is visible in full size and image "2" is visible partially (thus giving a clue to the user that he can scroll the content). After scrolling scrool view must not stay in intermediate state and scrolling must be completed (like iOS's Scroll View does when "Paging Enabled" is turned on):

我拒绝使用 Horizo​​ntalScrollView ,因为它没有任何类似寻呼已启用属性。

I refused to use HorizontalScrollView, because it has nothing similar to "Paging Enabled" property.

谷歌搜索后,我碰到 android.support.v4.view.ViewPager 。它的滚动行为完全是我想要的,但我也不好主意如何支持 ViewPager 部分可见的下一个形象呢?从技术上讲,我应该回报在

After googling, I came across android.support.v4.view.ViewPager. It's scrolling behavior is perfectly what I want, but I have no good idea how to support "partially visible" next image in ViewPager? Technically, what should I return in the

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)?

对于present,我的code是

For the present, my code is

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    View view = inflater.inflate(R.layout.stage_select_image_layout, container, false);
    ImageView imageView = (ImageView) view.findViewById(R.id.stage_select_image_layout_image);
    imageView.setImageResource(m_imageResourceId);
    return view;
}

但它会导致每页只有一个形象的行为,不是我想要的(见第一个图)。

But it results in "exactly one image per page" behavior, not what I want (see the very first figure).

推荐答案

这是卓有成效的:

    ViewPager pager = ...;
    pager.setOffscreenPageLimit(2);
    pager.setPageMargin(-200);

这篇关于安卓ViewPager定制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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