android - Android ViewPager 不刷卡
问题描述
我的应用程序包含选项卡和 ScrollView。当我在设备上运行它时,我可以通过点击和向上/向下滚动来在选项卡之间切换,没有问题。但是,水平滑动(在选项卡之间)似乎不起作用。我的猜测是ViewPager和ScrollView之间存在冲突,或者缺少参数。我该如何解决?
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.user.myapplication.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView"
android:orientation="vertical"
android:background="@color/gray"
>
</LinearLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"/>
</android.support.v4.widget.DrawerLayout>
解决方案
推荐阅读
- python - Tkinter - 新窗口上的按钮
- flutter - multi Provider doesn't work in material app in flutter?
- r - r中的字符/日期时间变量操作
- jenkins - Jenkins 推送后没有构建,但 Github webhook 正在工作
- laravel - 数组 laravel 验证“*”返回 true
- sql - 使用 Python 脚本将 SSRS 报告导出为 PDF
- cygwin - 在 git bash 中运行 Java 11 的 xjc 命令,但在 cygwin 中无效
- r - 从 R 中的 sapply 函数取回数据帧序列
- r - 使用 as.Date 和 tryFormats 来解析不同格式的日期
- amazon-web-services - 关系子对象的 Appsync 查询