title: OnTouchListener in Fragment
body: <p>I have this layout in my fragment:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/activity_main"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".ContenedorPrincipal"&gt;
  
  
  &lt;android.support.design.widget.FloatingActionButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:clickable="true"
      app:fabSize="mini"
      app:srcCompat="@android:drawable/btn_default"
      android:id="@+id/floatingActionButton"
      android:layout_alignParentRight="true"
      android:layout_alignParentEnd="true"
      android:layout_alignParentBottom="true" /&gt;
  
  &lt;Button
      android:text="@string/next"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:id="@+id/button"
      android:layout_alignParentStart="true"
      android:layout_alignParentLeft="true"
      android:layout_toStartOf="@+id/floatingActionButton"
      android:layout_toLeftOf="@+id/floatingActionButton"/&gt;
  
  
  
      &lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/sv"
          android:layout_alignParentTop="true"
          android:layout_alignParentStart="true"
          android:layout_alignParentLeft="true"
          android:layout_above="@+id/button"&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/relativelayoutglobal"
              android:orientation="vertical"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:id="@+id/relativelayoutobligatorios"
                  android:orientation="vertical"&gt;
  
  
                  &lt;TextView
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textAppearance="?android:attr/textAppearanceLarge"
                      android:text="@string/obligatorios"
                      android:id="@+id/textViewirgeneral"
                      android:background="@color/naranja"
                      android:layout_marginTop="15dp"/&gt;
  
                  &lt;ImageView
                      android:layout_width="match_parent"
                      android:layout_height="2dp"
                      android:id="@+id/imageViewirgeneral"
                      android:background="@color/black" /&gt;
  
                  //Here are some textinputlayout
  
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:id="@+id/relativelayoutgeneral"
                  android:orientation="vertical"&gt;
  
                  &lt;TextView
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textAppearance="?android:attr/textAppearanceLarge"
                      android:text="@string/general"
                      android:id="@+id/textViewiugeneral"
                      android:background="@color/naranja"
                      android:layout_marginTop="15dp"/&gt;
  
                  &lt;ImageView
                      android:layout_width="match_parent"
                      android:layout_height="2dp"
                      android:id="@+id/imageViewiugeneral"
                      android:background="@color/black" /&gt;
  
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:id="@+id/relativelayoutsuelo"
                  android:orientation="vertical"&gt;
  
                  &lt;TextView
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textAppearance="?android:attr/textAppearanceLarge"
                      android:text="@string/suelo"
                      android:id="@+id/textViewiusuelo"
                      android:background="@color/naranja"
                      android:layout_marginTop="15dp"/&gt;
  
                  &lt;ImageView
                      android:layout_width="match_parent"
                      android:layout_height="2dp"
                      android:id="@+id/imageViewiusuelo"
                      android:background="@color/black" /&gt;
  
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:id="@+id/relativelayoutcon"
                  android:orientation="vertical"&gt;
  
                  &lt;TextView
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textAppearance="?android:attr/textAppearanceLarge"
                      android:text="@string/construccion"
                      android:id="@+id/textViewiucons"
                      android:background="@color/naranja"
                      android:layout_marginTop="15dp"/&gt;
  
                  &lt;ImageView
                      android:layout_width="match_parent"
                      android:layout_height="2dp"
                      android:id="@+id/imageViewiucons"
                      android:background="@color/black" /&gt;
  
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:id="@+id/relativelayoutcomp"
                  android:orientation="vertical"&gt;
  
                  &lt;TextView
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textAppearance="?android:attr/textAppearanceLarge"
                      android:text="@string/inmueblecompleto"
                      android:id="@+id/textViewiucomp"
                      android:background="@color/naranja"
                      android:layout_marginTop="15dp"/&gt;
  
                  &lt;ImageView
                      android:layout_width="match_parent"
                      android:layout_height="2dp"
                      android:id="@+id/imageViewiucomp"
                      android:background="@color/black" /&gt;
  
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:id="@+id/relativelayoutamort"
                  android:orientation="vertical"&gt;
  
                  &lt;TextView
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textAppearance="?android:attr/textAppearanceLarge"
                      android:text="@string/amortizaciones"
                      android:id="@+id/textViewiuamort"
                      android:background="@color/naranja"
                      android:layout_marginTop="15dp"/&gt;
  
                  &lt;ImageView
                      android:layout_width="match_parent"
                      android:layout_height="2dp"
                      android:id="@+id/imageViewiuamort"
                      android:background="@color/black" /&gt;
  
              &lt;/LinearLayout&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/ScrollView&gt;
  </code></pre>
  
  <p></p>
  
  <p>I need to react to the user swipping right or left, so, in the fragment that uses this layout, I implemented View.OnTouchListener, and overrode the OnTouch method:</p>
  
  <pre><code>@Override
  public boolean onTouch(View v, MotionEvent event) {
  
      if(!touching){
          Log.i("TAG", "onTouch llamado");
  
          int action = event.getActionMasked();
  
          switch (action) {
  
              case MotionEvent.ACTION_DOWN:
                  initialX = event.getX();
                  initialY = event.getY();
                  Log.d("TAG", "Action was DOWN");
  
                  break;
  
              case MotionEvent.ACTION_UP:
                  float finalX = event.getX();
                  float finalY = event.getY();
  
                  Log.d("TAG", "Action was UP");
  
                  if (initialX &lt; finalX) {
                      Log.d("TAG", "Left to Right swipe performed");
                  }
  
                  if (initialX &gt; finalX) {
                      Log.d("TAG", "Right to Left swipe performed");
                      validate();
                  }
  
                  if (initialY &lt; finalY) {
                      Log.d("TAG", "Up to Down swipe performed");
                  }
  
                  if (initialY &gt; finalY) {
                      Log.d("TAG", "Down to Up swipe performed");
                  }
  
                  initialX=0F;
                  initialY=0F;
                  finalX=0F;
                  finalY=0F;
  
                  break;
  
              case MotionEvent.ACTION_CANCEL:
                  Log.d("TAG","Action was CANCEL");
                  break;
  
              case MotionEvent.ACTION_OUTSIDE:
                  Log.d("TAG", "Movement occurred outside bounds of current screen element");
                  break;
          }
          return true;
      }else{
          return false;
      }
  
  }
  </code></pre>
  
  <p>This way, the OnTouch method is not called. I have tried setting the OnTouchListener in each and every one of the different LinearLayout of my xml, and that way the OnTouch method is called, as long I am not touching in the space where another component (like the TextInputLayout) is. I would like the OnTouch be called everywhere in the parent layout, but still being able to use the TextInputLayout. I tried setting onTouchListener on the TextInputLayouts, but then they stop working as intended, and act like they wasn't enabled.</p>
  
  <p>I would like to avoid using ViewPager because I have a lot of functionality that must be changed if I need to use that component.</p>
  
  <p>How could I make the whole layout to react to OnTouch, while keeping the TextInputLayout working?</p>
  
  <p>Thank you.</p>