title: android button release pressed
body: <p><a href="https://i.stack.imgur.com/dOHYQ.jpg" rel="nofollow noreferrer">See problem in photo</a></p>
  
  <p>I am using selector and Touch listener to set button pressed on MotionEvent.ACTION_DOWN in fragment. But when Context Menu is called button become not pressed.This onTouch method inside fragment:</p>
  
  <pre><code> @Override
  public boolean onTouch(View view, MotionEvent motionEvent) {
      if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
          switch (view.getId()) {
              case R.id.buttonRow:
                  if (!buttonRow.isPressed()) {
                      buttonRow.setPressed(true);
                      buttonGrid.setPressed(false);
                      setLinearManager();
                  }
                  break;
              case R.id.buttonGrid:
                  if (!buttonGrid.isPressed()) {
                      buttonGrid.setPressed(true);
                      buttonRow.setPressed(false);
                      setGridManager();
                  }
                  break;
          }
      }
      return true;
  }
  </code></pre>
  
  <p>Fragment xml where buttons located:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.example.boss.lesson5.fragments.RecyclerViewFragment"&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"
      android:orientation="horizontal"&gt;
  
      &lt;ImageButton
          android:id="@+id/buttonRow"
          android:layout_width="match_parent"
          android:layout_height="60dp"
          android:layout_weight="1"
          android:adjustViewBounds="true"
          android:background="@drawable/button_effect"
          android:padding="15dp"
          android:scaleType="centerInside"
          android:src="@drawable/row" /&gt;
  
      &lt;ImageButton
          android:id="@+id/buttonGrid"
          android:layout_width="match_parent"
          android:layout_height="60dp"
          android:layout_weight="1"
          android:adjustViewBounds="true"
          android:background="@drawable/button_effect"
          android:padding="15dp"
          android:scaleType="centerInside"
          android:src="@drawable/grid" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;android.support.v7.widget.RecyclerView
      android:id="@+id/recycler"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_marginTop="60dp" /&gt;
  </code></pre>
  
  <p></p>