水平滚动视图中ViewPager [英] Horizontal Scroll View inside ViewPager
问题描述
我有水平滚动页面为在Android Market(ViewPager)。
I have horizontal scrolling pages as in the android market (ViewPager).
我的问题是,我想有一个横向滚动视图在其中一些照片?这是可能的?
My problem is that i want to have a Horizontal Scrolling View in them with some images?Is that possible??
截至目前,即时得到一点点滚动在我看来,然后在整个页面滚动。
As now,i m getting a little scroll in my view and then the whole page is scrolling.
感谢您的时间!
推荐答案
您需要延长 HorizontalScrollView
和拦截触摸事件。什么工作对我来说是下面的示例:
You need to extend the HorizontalScrollView
and intercept touch events. What worked for me was the following sample:
public class MyScrollView extends HorizontalScrollView {
public MyScrollView(Context p_context, AttributeSet p_attrs)
{
super(p_context, p_attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent p_event)
{
return true;
}
@Override
public boolean onTouchEvent(MotionEvent p_event)
{
if (p_event.getAction() == MotionEvent.ACTION_MOVE && getParent() != null)
{
getParent().requestDisallowInterceptTouchEvent(true);
}
return super.onTouchEvent(p_event);
}
}
然后,而不是在布局XML使用 HorizontalScrollView
,你需要使用这个自定义视图。
Then, instead of using the HorizontalScrollView
in your layout XML, you need to use this custom view.
什么帮助我得到这个解决方案是这个帖子
What helped me get to this solution is this post
这篇关于水平滚动视图中ViewPager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!