Android 无法在viewpager中垂直滚动
几天来,我一直在尝试使用片段实现带有ViewPager的TabLayout。当显示片段并在选项卡之间滑动时,我无法在ViewPager中当前显示的片段中垂直滚动 我在上找到了一些解决方案,建议在片段或活动布局中实现(嵌套)滚动视图,以使内容滚动。我尝试过几种方法(但都不管用)——我得出结论,我做错了什么,到目前为止,我还无法找出答案 我使用以下代码来实现当前结果: activity.xmlAndroid 无法在viewpager中垂直滚动,android,scroll,android-viewpager,scrollview,Android,Scroll,Android Viewpager,Scrollview,几天来,我一直在尝试使用片段实现带有ViewPager的TabLayout。当显示片段并在选项卡之间滑动时,我无法在ViewPager中当前显示的片段中垂直滚动 我在上找到了一些解决方案,建议在片段或活动布局中实现(嵌套)滚动视图,以使内容滚动。我尝试过几种方法(但都不管用)——我得出结论,我做错了什么,到目前为止,我还无法找出答案 我使用以下代码来实现当前结果: activity.xml <?xml version="1.0" encoding="utf-8"?><andro
<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
<RelativeLayout
android:id="@+id/scV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.TabLayout
android:id="@+id/caj_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/door_img [exists, not pasted]"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:visibility="visible" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@id/door_img"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
我希望能够在片段中滚动,但是,这是不可能的。
我是否错过了xml标记?
非常感谢您的帮助。我遇到了完全相同的问题,您能解决吗?
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Test">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest"
android:textSize="80sp" />
</FrameLayout>
TabLayout tabs = (TabLayout) findViewById(R.id.caj_tab_layout);
final ViewPager pager = (ViewPager) findViewById(R.id.pager);
final PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager());
pager.setAdapter(adapter);
tabs.setupWithViewPager(pager);