无法与弹出窗口和背景(Google Map)进行交互

时间:2013-03-03 20:44:59

标签: android android-widget popupwindow google-maps-android-api-2

当我点击地图标记时,我会显示一个PopupWindow。 PopupWindow允许用户更改标记的位置并选择其周围的半径。如果我将focusable设置为true,我可以与PopupWindow进行交互,但不能与地图进行交互。并且,如果我将焦点设置为false,奇怪的是,我可以在PopupWindow上交互SeekBar,但Buttons和EditText都没有响应,但我可以与地图进行交互。

问题:我怎样才能让用户同时与PopupWindow和地图互动?

        <LinearLayout android:layout_width="0dp" 
            android:layout_height="wrap_content" 
            android:layout_weight="1" 
            android:orientation="vertical">

            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/event" 
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <EditText android:id="@+id/markerEventNameEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="@string/your_event_name"
                android:inputType="text" />

            <LinearLayout android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/radius"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView android:id="@+id/radiusTextView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceSmall" />
            </LinearLayout>

            <SeekBar android:id="@+id/radiusSeekBar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp" />

            <LinearLayout android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <Button android:id="@+id/editEventButton"
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="@string/edit_event" />

                <Button android:id="@+id/cancelMarkerWindowButton"
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="@string/close" />
            </LinearLayout>
        </LinearLayout>

        <TableLayout android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical">

            <TableRow android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
                android:gravity="center">

                <ImageButton android:id="@+id/ImageButton03"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_gravity="center"
                    android:src="@drawable/arrow_1" />
            </TableRow>

            <TableRow android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <ImageButton android:id="@+id/ImageButton01"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:src="@drawable/arrow_1"/>

                <ImageButton android:id="@+id/ImageButton02"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:src="@drawable/arrow_1"/>
            </TableRow>

            <TableRow android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center">

                <ImageButton android:id="@+id/imageButton1"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:src="@drawable/arrow_1" />
            </TableRow>
        </TableLayout>
    </LinearLayout>
    <View android:layout_width="match_parent"
        android:layout_height="3dp"
        android:background="@color/WhiteSmoke" />

    //Constructor
    public MarkerPopupWindow(Marker edited_event_marker,Context context)
    {   
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View markerWindowView = inflater.inflate(R.layout.event_editor_popup_window, null, false);
        markerWindowView.findViewById(R.id.cancelMarkerWindowButton);

        int height =  ViewGroup.LayoutParams.WRAP_CONTENT;
        int width = ViewGroup.LayoutParams.MATCH_PARENT;
        PopupWindow markerWindow = new PopupWindow(markerWindowView,
                width,height,
                false); //Focusable, if false window cannot be touched.
        markerWindow.setWindowLayoutMode(width, height);
        //Called these methods (commented out) attempting to fix the problem without success.
        //markerWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        //markerWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        //markerWindow.setOutsideTouchable(true);
        markerWindow.showAtLocation(findViewById(R.id.location_tab_container), Gravity.TOP, 0, 0);
    }

1 个答案:

答案 0 :(得分:1)

你使用弹出窗口的方式是地图或弹出窗口可以有焦点,如果你想能够在弹出窗口的情况下移动地图我认为你可能需要从地图api获得弹出窗口,就像点击标记时谷歌地图的显示方式一样。

有关弹出窗口的更多信息(在地图api中称为InfoWindow),您可以here