0

I am working on MultiDirectionSlidingDrawer motion events. I have a problem on Action_Move.

I am unable to set Visible or Gone layouts on Action_Move.

I have handle with two buttons. When I drag click on first button it should show the first view also the same for second button.

    slidingDrawer.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_MOVE) {
                   int width = getActivity().getWindowManager()
                        .getDefaultDisplay().getWidth();
                width = width / 2;
                if (event.getX() < width) {
                    System.out.println("Visible view 1"); 
                    view1.setVisibility(View.VISIBLE);
                    view2.setVisibility(View.GONE);
                }else{  
                    System.out.println("Visible view 2"); 
                    view1.setVisibility(View.GONE);
                    view2.setVisibility(View.VISIBLE);
                }  
            }
         }
     }

My xml view :

   <com.myproject.widget.MultiDirectionSlidingDrawer
        xmlns:my="http://schemas.android.com/apk/res/com.lesmobilizers.chronoresto"
        android:id="@+id/drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:content="@+id/content"
        app:direction="topToBottom"
        app:handle="@+id/handle" >

        <LinearLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white"
            android:orientation="vertical" >

            <LinearLayout
            android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/gray"
            android:orientation="vertical"
            android:visibility="gone" />

             <LinearLayout
            android:id="@+id/view2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/black"
            android:orientation="vertical" /> 

           </LinearLayout>


           <LinearLayout
            android:id="@+id/handle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/menufiche_content"
            android:layout_marginTop="-24dp"
            android:background="@drawable/btn_restaurant_pannel_switch_close"
            android:orientation="horizontal"
            android:weightSum="2" >

            <LinearLayout
                android:id="@+id/lt_menu"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="horizontal" >

                <com.myproject.widget.FontCustomTextView
                    android:id="@+id/menutext"
                    style="@style/font_button_bold"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:drawablePadding="5dp"
                    android:drawableRight="@drawable/img_arrow_down"
                    android:text="Menu  "
                    android:textColor="@color/gray"
                    android:textSize="17sp" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/lt_fiche"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="horizontal" >

                <com.myproject.widget.FontCustomTextView
                    android:id="@+id/fichetxt"
                    style="@style/font_button_bold"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:drawablePadding="5dp"
                    android:drawableRight="@drawable/img_arrow_down"
                    android:text="Fiche  "
                    android:textColor="@color/gray"
                    android:textSize="17sp" />
            </LinearLayout>
        </LinearLayout>
    </com.myproject.widget.MultiDirectionSlidingDrawer>

System.out are working fine. But the thing is view1, view2 Visibilities are not working as my code says.

I hope you are getting my problem. I need your suggestion about Action_Move.

Aristo Michael
  • 2,166
  • 3
  • 35
  • 43

0 Answers0