问题描述
我要显示左,右箭头在我ViewPager,以表明刷卡。
I want to show left and right arrows over my ViewPager, to indicate swiping.
我加了两个ImageButtons在ViewPager元素,但这些地区再从触发了刷卡阻止ViewPager。
I added two ImageButtons over the ViewPager-element but those areas then block the ViewPager from triggering the "swiping".
我也想对这些箭头presses触发片段相应地改变。
I also want presses on those arrows to trigger the fragment to change accordingly.
在短:该ImageButtons不应该干涉刷卡,但他们应该注册pressing
In short: The ImageButtons should not interfere with swiping but they should register pressing.
我怎样才能做到这一点?谢谢!
How can I achieve this?Thanks!
推荐答案
我想出了一个解决方案。这是非常简单的。
I figured out a solution. It's very simple.
而不是使用ImageButtons显示的箭头,我现在使用ImageViews,因为他们通过任何触摸事件下面的图层。
Instead of using ImageButtons for displaying the arrows, I now use ImageViews because they pass on any touch events to the layer underneath.
然后,我把透明按钮上的片段,而不是自己,这样,他们就不会挡住ViewPagers刷卡行为,但他们会火的onClick事件!
Then, I put transparent Buttons on the fragments themselves instead, that way they won't block the ViewPagers swiping behaviour but they will fire onClick Events!
这篇关于通过ViewPager左右箭头指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!