我試圖實現像GoogleMap
全屏幕布局和ViewPager
在底部的功能。谷歌地圖與ViewPager在底部,ViewPagerFragment項目全屏滾動
現在ViewPager
最初將在底部,用戶可以垂直滾動,如果它的內容高度大。用戶應該能夠以全屏方式進行滾動(根據下面的演示圖像,可以從底部到頂部切換到ViewPager的頁面項目高度)。
目前,我可以通過ScrollView
(with match_parnt height and paddingTop like 380dp)在ViewPager的片段(佈局代碼如下)中獲得相同的UI效果。
現在我現在面臨的問題是GoogleMap
由於ViewPager
片段的match_parent
高度而沒有響應任何觸摸/點擊事件。
我的預期結果是GoogleMap
必須能夠監聽觸摸/點擊事件,ViewPager的片段必須可以從底部到頂部方向垂直滾動。
我在搜索過程中發現我們可以使用requestDisallowInterceptTouchEvent
使子視圖來監聽這些觸摸/點擊事件。但在我的情況下ViewPager和ScrollView裏面的片段正在採取所有的觸摸/點擊事件。
片編,
activity.xml
<FrameLayout
...
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
...
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
... />
<android.support.v7.widget.Toolbar
...
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
... />
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
viewpager_fragment_item.xml
<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>
預計輸出演示
在本演示中,用戶可以觸摸,放大/縮小Map
,可以滑動ViewPager
和滾動ViewPager的Fragemt全屏顯示。所以,這就是我想要達到的目標。
如果有人給予有用的鏈接或一些演示,我將不勝感激。
請幫忙!
感謝。