Search code examples
androidandroid-layoutandroid-sliding

disable all clicks in layout


In my application I have slidingPaneLayout

 <com.abc.qwe.widget.SlidingPaneLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/sp"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <LinearLayout
                android:id="@+id/drawer_view"
                android:layout_width="@dimen/drawer_size"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_gravity="start"
                android:background="@color/main_blue_color">

            <ListView
                    android:id="@+id/left_drawer"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:choiceMode="singleChoice"
                    android:scrollbars="none"
                    android:divider="@color/menu_list_divider_color"
                    android:dividerHeight="1dp"
                    android:layout_weight="1"
                    android:footerDividersEnabled="false"
                    android:cacheColorHint="@android:color/transparent"
                    android:listSelector="@drawable/selector_list"
                    android:headerDividersEnabled="true"/>

        </LinearLayout>

        <RelativeLayout
android:id="@+id/aaa
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            <FrameLayout
                    android:id="@+id/content_frame"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

            </FrameLayout>

        </RelativeLayout>

    </com.abc.qwe.widget.SlidingPaneLayout>

When slidingPaneLayout is opened I want disable all clicks, swipes any actions in FrameLayout.

When slidingPaneLayout is closed I want enable all clicks, swipes any actions in FrameLayout.

How could I do this?

RelativeLayout layout = (RelativeLayout) findViewById(R.id.aaa);
                for (int i = 0; i < layout.getChildCount(); i++) {
                    View child = layout.getChildAt(i);
                    child.setEnabled(false);
                } 

I did this but it doesn't work.


Solution

  • in your onClickListener , check if the slidingPanelLayout is opened or not,

    if (opened){
       return ;
    }
    

    you may assume it is opened/ closed , when the offset of the slidingPanelLayout is 0 or equal to the screen width.