1
我需要將MapView添加到例外列表,以便在用戶觸摸地圖視圖時滾動視圖不會滾動。在父滾動視圖中向數組添加片段
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.xxx.ScrollViewWithMap
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:id="@+id/base_scrollview">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/content_fragment"
android:layout_marginBottom="5dp" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/map_fragment"
android:layout_margin="10dp" />
</LinearLayout>
</org.xxx.ScrollViewWithMap>
</RelativeLayout>
在基地片段mapFragment加入通過:
LocationMapFragment locationMapFragment = new LocationMapFragment();
locationMapFragment.setArguments(args);
getChildFragmentManager().beginTransaction().add(R.id.map_fragment, locationMapFragment).commit();
現在我需要這個視圖添加到在ScrollViewWithMap數組,但我怎樣才能做到這一點。在基礎片段中,'locationMapFragment'爲getView()返回null,我不知道如何從片段中訪問scrollView。
[編輯:] 我也嘗試添加上onAttach的片段,但觀點仍然是 '空':
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnFragmentInteractionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnFragmentInteractionListener");
}
ScrollViewWithMap scrollview = (ScrollViewWithMap) activity.findViewById(R.id.base_scrollview);
scrollview.addInterceptScrollView(this.getView());
}
感謝我將有一個看。目前我使用動作識別器實現了一個透明的圖像疊加層,但對舊版本來說這似乎不起作用。 –