Android 底部带有ViewPager的Google地图,ViewPagerFragment项目可全屏滚动

Android 底部带有ViewPager的Google地图,ViewPagerFragment项目可全屏滚动,android,Android,我正在尝试使用全屏布局和底部的ViewPager实现类似于GoogleMap的功能 现在,ViewPager最初将位于底部,如果内容高度较大,用户可以垂直滚动。用户应该能够在全屏上滚动(从下到上直到ViewPager的页面项目高度,如下图所示) 目前,我可以借助ViewPager片段中的ScrollView(具有匹配参数高度及其类似于380dp的paddingTop)实现相同的UI效果(布局代码如下所示) 我现在面临的问题是,GoogleMap由于ViewPagerFragment的match\

我正在尝试使用全屏布局和底部的
ViewPager
实现类似于
GoogleMap
的功能

现在,
ViewPager
最初将位于底部,如果内容高度较大,用户可以垂直滚动。用户应该能够在全屏上滚动(从下到上直到ViewPager的页面项目高度,如下图所示)

目前,我可以借助ViewPager片段中的
ScrollView
(具有匹配参数高度及其类似于380dp的paddingTop)实现相同的UI效果(布局代码如下所示)

我现在面临的问题是,
GoogleMap
由于
ViewPager
Fragment的
match\u parent
高度,对任何触摸/点击事件都没有响应

我的预期结果是
GoogleMap
必须能够监听触摸/点击事件,并且ViewPager的片段必须能够在地图上从下到上垂直滚动

我在搜索过程中发现,我们可以使用
requestDisallowWinterCeptTouchEvent
使子视图监听那些触摸/点击事件。但在我的例子中,ViewPager和ScrollView在片段内部处理所有的触摸/点击事件

一段代码

activity.xml


在本演示中,用户可以触摸、放大/缩小
地图
、滑动
查看页面
、全屏滚动查看页面。这就是我想要达到的目标

如果有人提供有用的链接或演示,我将不胜感激

请帮忙


谢谢。

好的,使用
底页
布局解决它

让我向您展示我的一段布局代码以完全理解它

<android.support.design.widget.CoordinatorLayout
    ...
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    ... >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <fragment xmlns:map="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            .... />

       <!-- Other layout component code like Toolbar-->

    </RelativeLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/bottomSheet"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

        <android.support.v4.view.ViewPager
            ...
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            ... />
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
我做了一个演示,你可以找到它

<ScrollView
    ...
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    ... >

    <LinearLayout
        ...
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingTop="380dp" >

    <!-- 
            child views in here.
        -->
    </LinearLayout>
</ScrollView>
<android.support.design.widget.CoordinatorLayout
    ...
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    ... >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <fragment xmlns:map="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            .... />

       <!-- Other layout component code like Toolbar-->

    </RelativeLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/bottomSheet"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

        <android.support.v4.view.ViewPager
            ...
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            ... />
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
    View bottomSheet = findViewById(R.id.bottomSheet);
    mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
    mBottomSheetBehavior.setPeekHeight(300);
    mBottomSheetBehavior.setHideable(false);
    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_DRAGGING);