Open a PopupWindow and let the outsides still touchable

徘徊边缘 提交于 2019-12-05 07:53:35

As per javadocs

Controls whether the pop-up will be informed of touch events outside of its window. This only makes sense for pop-ups that are touchable but not focusable

So your line

 window.setFocusable(true);

causes the method setOutsideTouchable() to do nothing.

just like the ernazm say

As per javadocs

Controls whether the pop-up will be informed of touch events outside of its window. This only makes sense for pop-ups that are touchable but not focusable

and it's work on

window.setTouchable(true);
window.setFocusable(false);
window.setOutsideTouchable(false);

When window touchalbe is true, focusable is false, setOutsideTouchable() is work, if setOutsideTouchable(true), touch outside of popupwindow will dismiss, otherwise the outside of popupwindows still can be touchable without dismiss.

For that you have to made the Custom Popup window. In that u have to call the another layout. So in this way You can access the other component also. It just the One type of the Layout. But you can set its appearence as Popup Window.

<!-- POPUP MENU -->
    <RelativeLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/popup_window"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/fullwindowborderforpopup"
        >



        <LinearLayout

            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"

            android:padding="1px"
            android:layout_marginTop="15dip"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_marginBottom="10dip"
            android:background="@drawable/borderforpopup"
            >
            <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical" 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:layout_marginTop="5dip"
                android:layout_marginLeft="3dip"
                android:layout_marginRight="3dip"
                android:layout_marginBottom="3dip">

                <TextView 
                    android:id="@+id/tital_of_popup"
                    android:gravity="center_vertical|center_horizontal" 
                    android:layout_height="wrap_content" 
                    android:layout_width="wrap_content"
                    android:text="Event Registration"
                    android:textStyle="bold"
                    android:textColor="#ffffff" 
                    />
            </LinearLayout>

            <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical" 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:layout_marginTop="5dip"
                android:layout_marginLeft="3dip"
                android:layout_marginRight="3dip"
                android:layout_marginBottom="3dip"
            >

                <TextView 
                    android:id="@+id/message_of_popup"
                    android:gravity="center_vertical|center_horizontal" 
                    android:layout_height="wrap_content" 
                    android:text="Please fill all the data" 
                    android:layout_width="wrap_content"
                    android:textStyle="normal"
                    android:textColor="#ffffff" />
        </LinearLayout>
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:layout_marginTop="5dip"
            android:layout_marginLeft="6dip"
            android:layout_marginRight="6dip"
            android:layout_marginBottom="9dip"
                >


             <Button 
                android:layout_height="fill_parent" 
                android:id="@+id/okbutton" 
                android:text="OK" 
                android:textColor="#ffffff"
                android:shadowColor="#000000"
                android:gravity="center" 
                android:layout_width="fill_parent"
                android:background="@drawable/buttonborderframe"/>
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

try this. And you can hide and show the layout whenever you want. And other fields are accessable.

Mohamed

Try adding this to your code:

window.setOutsideTouchable(true);

From the Android documentation:

void setOutsideTouchable (boolean touchable)

Controls whether the pop-up will be informed of touch events outside of its window. This only makes sense for pop-ups that are touchable but not focusable, which means touches outside of the window will be delivered to the window behind. The default is false.

If the popup is showing, calling this method will take effect only the next time the popup is shown or through a manual call to one of the update() methods.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!