【发布时间】:2016-01-12 05:24:33
【问题描述】:
我有一个 AppCompatActivity,其布局包含一个 FrameLayout。在那个FrameLayout 中,我放置了一个包含更复杂布局的片段:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/top_toolbar" />
<android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/bottom_toolbar" />
<com.passionusnetworks.lype.plugins.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/abc_action_bar_default_height_material"
android:background="#00000000"
android:elevation="2dp" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" />
<include layout="@layout/navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
然后我将 2 个Fragment 放入ViewPager。使用我的SlidingTabLayout,我可以通过按下这些选项卡在我的 2 个片段之间切换。在这些片段中,有一个RecyclerView。我的问题是似乎没有触摸事件到达我的片段(RecyclerViews 无法滚动,我无法在ViewPager 的片段之间滑动。我试图在所有级别上放置一些OnTouchListener,但我永远无法获取单个MotionEvent。
我不知道该怎么做才能找到我的片段中无法获得任何触摸事件的原因。有人有什么建议吗?
【问题讨论】:
-
试试这个link。它应该工作
-
我已经尝试过
OnTouchListener,就像我说的那样,它没有用,当我点击或滑动时我没有得到MotionEvent。我也尝试了requestDisallowInterceptTouchEvent(true);,但没有成功,但我不确定我是否把它放在了正确的位置。
标签: android android-fragments android-viewpager