将线性布局更改为相对布局后,滑动更改不起作用。
这里是完整的 xml 代码。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/singleSlider"
android:layout_width="match_parent"
android:layout_height="@dimen/slider_height"
android:background="@color/colorPrimaryDark" />
<android.support.v4.widget.NestedScrollView
android:id="@+id/singleScroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
可能会出现什么问题?
它也不适用于框架布局。
有什么建议吗?
最佳答案
NestedScrollView
现在位于 ViewPager
上方(z 轴),因此 ViewPager
不会接收触摸事件。
添加
android:layout_below="@+id/singleSlider"
到您的NestedScrollView
。
关于java - 为什么 ViewPager 不能在relativelayout中滑动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52277140/