title: ScrollView inside ViewPager does not scroll on Android 4.x
body: <p>I have a problem that seems to only impact Android 4.x versions and may be also device specific (i.e. it does not exist on my Huawei G630@4.3, but do exists on a Samsung Ace2@4.4.4).
  I have a <code>ScrollView</code> that contains a <code>RelativeLayout</code> that has 4 <code>CardView</code>s. Now on some 4.x devices, the scroll event simply does not happen when I try to scroll beginning from a card. If I touch the small padding between the cards or above <strong>the first</strong> card (and not <strong>between</strong> any two) and the device screen, I can scroll the content.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fillViewport="true"&gt;
  
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      xmlns:app="http://schemas.android.com/tools"
                      xmlns:card_view="http://schemas.android.com/apk/res-auto"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:orientation="vertical"
                      android:padding="@dimen/activity_horizontal_margin"&gt;
  
          &lt;android.support.v7.widget.CardView
              android:id="@+id/metricsContainerCard"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="10dp"
              app:cardElevation="2dp"
              card_view:cardUseCompatPadding="true"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical"
                  android:padding="10dp"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"&gt;
  
                      &lt;ImageView
                          android:layout_width="20dp"
                          android:layout_height="20dp"
                          android:layout_gravity="center_vertical"
                          android:layout_marginRight="5dp"
                          android:src="@drawable/metrics"/&gt;
  
                      &lt;TextView
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:text="@string/metrics"
                          android:textSize="20sp"/&gt;
                  &lt;/LinearLayout&gt;
  
  
                  &lt;View
                      android:layout_width="match_parent"
                      android:layout_height="1dp"
                      android:background="@color/projectCircleBackgroundShadow"/&gt;
  
              &lt;/LinearLayout&gt;
  
          &lt;/android.support.v7.widget.CardView&gt;
  
          &lt;android.support.v7.widget.CardView
              android:id="@+id/warningsContainerCard"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="10dp"
              android:layout_below="@id/metricsContainerCard"
              app:cardElevation="2dp"
              card_view:cardUseCompatPadding="true"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical"
                  android:padding="10dp"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"&gt;
  
                      &lt;ImageView
                          android:layout_width="20dp"
                          android:layout_height="20dp"
                          android:layout_gravity="center_vertical"
                          android:layout_marginRight="5dp"
                          android:src="@drawable/bug_color"/&gt;
  
                      &lt;TextView
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:text="@string/warnings"
                          android:textSize="20sp"/&gt;
                  &lt;/LinearLayout&gt;
  
  
                  &lt;View
                      android:layout_width="match_parent"
                      android:layout_height="1dp"
                      android:background="@color/projectCircleBackgroundShadow"/&gt;
  
              &lt;/LinearLayout&gt;
          &lt;/android.support.v7.widget.CardView&gt;
  
          &lt;android.support.v7.widget.CardView
              android:id="@+id/topWarningsContainerCard"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_below="@id/warningsContainerCard"
              android:layout_marginTop="10dp"
              app:cardElevation="2dp"
              card_view:cardUseCompatPadding="true"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical"
                  android:padding="10dp"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"&gt;
  
                      &lt;ImageView
                          android:layout_width="20dp"
                          android:layout_height="20dp"
                          android:layout_gravity="center_vertical"
                          android:layout_marginRight="5dp"
                          android:src="@drawable/top_warnings"/&gt;
  
                      &lt;TextView
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:text="@string/topWarnings"
                          android:textSize="20sp"/&gt;
                  &lt;/LinearLayout&gt;
  
  
                  &lt;View
                      android:layout_width="match_parent"
                      android:layout_height="1dp"
                      android:background="@color/projectCircleBackgroundShadow"/&gt;
  
              &lt;/LinearLayout&gt;
          &lt;/android.support.v7.widget.CardView&gt;
  
          &lt;android.support.v7.widget.CardView
              android:id="@+id/topCriticalItemsContainerCard"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_below="@id/topWarningsContainerCard"
              android:layout_marginTop="10dp"
              app:cardElevation="2dp"
              card_view:cardUseCompatPadding="true"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical"
                  android:padding="10dp"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"&gt;
  
                      &lt;ImageView
                          android:layout_width="20dp"
                          android:layout_height="20dp"
                          android:layout_gravity="center_vertical"
                          android:layout_marginRight="5dp"
                          android:src="@drawable/top_critical_items"/&gt;
  
                      &lt;TextView
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:text="@string/topCriticalItems"
                          android:textSize="20sp"/&gt;
  
                  &lt;/LinearLayout&gt;
  
  
                  &lt;View
                      android:layout_width="match_parent"
                      android:layout_height="1dp"
                      android:background="@color/projectCircleBackgroundShadow"/&gt;
  
              &lt;/LinearLayout&gt;
          &lt;/android.support.v7.widget.CardView&gt;
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>There isn't any problem on Android 5.x and 6.x.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>It seems that problem is not exclusively related to <code>CardView</code>, as I have another layout, and it also does not scroll even when I drag the screen by the custom view:</p>
  
  <pre><code>&lt;ScrollView
      android:id="@+id/scrollView"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:card_view="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      tools:context=".projects.details.ProjectDetailsActivity_"&gt;
  
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:tools="http://schemas.android.com/tools"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:padding="@dimen/activity_horizontal_margin"&gt;
  
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"&gt;
  
              &lt;TextView
                  android:id="@+id/projectName"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginBottom="16dp"
                  android:ellipsize="none"
                  android:gravity="center_horizontal"
                  android:text="Project name"
                  android:textSize="24sp"/&gt;
  
              &lt;c.f.q.a.projects.details.components.widgets.ProjectDetailWidget
                  android:id="@+id/projectDetailWidget"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:layout_gravity="center"/&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
              android:id="@+id/timelineWrapperLayout"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"&gt;
  
              &lt;android.support.v7.widget.CardView
                  android:id="@+id/qualityTimelineCard"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="10dp"
                  app:cardElevation="2dp"
                  card_view:cardUseCompatPadding="true"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:orientation="vertical"
                      android:padding="10dp"&gt;
  
                      &lt;LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"&gt;
  
                          &lt;ImageView
                              android:id="@+id/flipQualityTimelineButton"
                              android:layout_width="30dp"
                              android:layout_height="30dp"
                              android:layout_marginRight="5dp"
                              android:src="@drawable/flip_to_cost"/&gt;
  
                          &lt;TextView
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_gravity="center_vertical"
                              android:ellipsize="end"
                              android:lines="1"
                              android:text="@string/project_timeline_title"
                              android:textSize="16dp"/&gt;
                      &lt;/LinearLayout&gt;
  
                      &lt;ProgressBar
                          android:id="@+id/projectQualityTimelineProgressBar"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          /&gt;
  
                      &lt;com.github.mikephil.charting.charts.LineChart
                          android:id="@+id/projectQualityTimeline"
                          android:layout_width="match_parent"
                          android:layout_height="200dp"
                          android:layout_marginTop="16dp"
                          android:tag="@string/project_chart_tag"
                          android:visibility="gone"/&gt;
                  &lt;/LinearLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
  
              &lt;android.support.v7.widget.CardView
                  android:id="@+id/costTimelineCard"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="10dp"
                  android:visibility="gone"
                  app:cardElevation="2dp"
                  card_view:cardUseCompatPadding="true"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:orientation="vertical"
                      android:padding="10dp"&gt;
  
                      &lt;LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"&gt;
  
                          &lt;ImageView
                              android:id="@+id/flipCostTimelineButton"
                              android:layout_width="30dp"
                              android:layout_height="30dp"
                              android:layout_marginRight="5dp"
                              android:src="@drawable/flip_to_quality"/&gt;
  
                          &lt;TextView
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_gravity="center_vertical"
                              android:ellipsize="end"
                              android:lines="1"
                              android:text="@string/project_cost_timeline_title"
                              android:textSize="16dp"/&gt;
                      &lt;/LinearLayout&gt;
  
  
                      &lt;ProgressBar
                          android:id="@+id/projectCostTimelineProgressBar"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"
                          /&gt;
  
                      &lt;com.github.mikephil.charting.charts.LineChart
                          android:id="@+id/projectCostTimeline"
                          android:layout_width="match_parent"
                          android:layout_height="200dp"
                          android:layout_marginTop="16dp"
                          android:tag="@string/project_chart_tag"
                          android:visibility="gone"/&gt;
                  &lt;/LinearLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;android.support.v7.widget.CardView
              android:id="@+id/vcsChangeCard"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="10dp"
              android:layout_weight="1"
              app:cardElevation="2dp"
              card_view:cardUseCompatPadding="true"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_gravity="left"
                  android:orientation="vertical"
                  android:padding="10dp"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"&gt;
  
                      &lt;ImageView
                          android:id="@+id/expandVcsChangeButton"
                          android:layout_width="28dp"
                          android:layout_height="28dp"
                          android:layout_marginRight="5dp"
                          android:src="@drawable/expand_chart"/&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center_vertical"
                          android:ellipsize="end"
                          android:maxLines="2"
                          android:text="@string/project_vcschange_title"
                          android:textSize="16sp"/&gt;
                  &lt;/LinearLayout&gt;
  
                  &lt;ProgressBar
                      android:id="@+id/vcsChangeProgressBar"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center"/&gt;
  
                  &lt;com.github.mikephil.charting.charts.BarChart
                      android:id="@+id/projectVcsChange"
                      android:layout_width="match_parent"
                      android:layout_height="175dp"
                      android:layout_marginTop="16dp"
                      android:tag="@string/project_chart_tag"
                      android:visibility="gone"/&gt;
              &lt;/LinearLayout&gt;
          &lt;/android.support.v7.widget.CardView&gt;
  
          &lt;android.support.v7.widget.CardView
              android:id="@+id/dtnosChangeCard"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="10dp"
              android:layout_weight="1"
              app:cardElevation="2dp"
              card_view:cardUseCompatPadding="true"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:gravity="right"
                  android:orientation="vertical"
                  android:padding="10dp"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"&gt;
  
                      &lt;ImageView
                          android:id="@+id/expandDtnosChangeButton"
                          android:layout_width="28dp"
                          android:layout_height="28dp"
                          android:layout_marginRight="5dp"
                          android:src="@drawable/expand_chart"/&gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center_vertical"
                          android:ellipsize="end"
                          android:maxLines="2"
                          android:text="@string/project_systemchange_title"
                          android:textSize="16sp"/&gt;
                  &lt;/LinearLayout&gt;
  
                  &lt;ProgressBar
                      android:id="@+id/dtnosChangeProgressBar"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center"/&gt;
  
                  &lt;com.github.mikephil.charting.charts.BarChart
                      android:id="@+id/projectDtnosChange"
                      android:layout_width="match_parent"
                      android:layout_height="175dp"
                      android:layout_marginTop="16dp"
                      android:tag="@string/project_chart_tag"
                      android:visibility="gone"/&gt;
              &lt;/LinearLayout&gt;
          &lt;/android.support.v7.widget.CardView&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"&gt;
  
              &lt;android.support.v7.widget.CardView
                  android:id="@+id/sensorNodeCard"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="10dp"
                  android:layout_weight="1"
                  app:cardElevation="2dp"
                  card_view:cardUseCompatPadding="true"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:gravity="left"
                      android:orientation="vertical"
                      android:padding="10dp"&gt;
  
                      &lt;LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"&gt;
  
                          &lt;ImageView
                              android:id="@+id/expandSensornodeButton"
                              android:layout_width="28dp"
                              android:layout_height="28dp"
                              android:layout_marginRight="5dp"
                              android:src="@drawable/expand_chart"/&gt;
  
                          &lt;TextView
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_gravity="center_vertical"
                              android:ellipsize="end"
                              android:maxLines="2"
                              android:text="@string/project_sensornode_title"
                              android:textSize="16sp"/&gt;
                      &lt;/LinearLayout&gt;
  
  
                      &lt;ProgressBar
                          android:id="@+id/sensorNodeProgressBar"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"/&gt;
  
                      &lt;com.github.mikephil.charting.charts.RadarChart
                          android:id="@+id/sensorNodeChart"
                          android:layout_width="match_parent"
                          android:layout_height="175dp"
                          android:layout_marginTop="16dp"
                          android:tag="@string/project_chart_tag"
                          android:visibility="gone"/&gt;
                  &lt;/LinearLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
  
              &lt;android.support.v7.widget.CardView
                  android:id="@+id/aggregateNodeCard"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="10dp"
                  android:layout_weight="1"
                  app:cardElevation="2dp"
                  card_view:cardUseCompatPadding="true"&gt;
  
                  &lt;LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:gravity="right"
                      android:orientation="vertical"
                      android:padding="10dp"&gt;
  
                      &lt;LinearLayout
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"&gt;
  
                          &lt;ImageView
                              android:id="@+id/expandAggregateButton"
                              android:layout_width="28dp"
                              android:layout_height="28dp"
                              android:layout_marginRight="5dp"
                              android:src="@drawable/expand_chart"/&gt;
  
                          &lt;TextView
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              android:layout_gravity="center_vertical"
                              android:ellipsize="end"
                              android:maxLines="2"
                              android:text="@string/project_aggregatenode_title"
                              android:textSize="16sp"/&gt;
  
                      &lt;/LinearLayout&gt;
  
                      &lt;ProgressBar
                          android:id="@+id/aggregateNodeProgressBar"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_gravity="center"/&gt;
  
                      &lt;com.github.mikephil.charting.charts.RadarChart
                          android:id="@+id/aggregateNodeChart"
                          android:layout_width="match_parent"
                          android:layout_height="175dp"
                          android:layout_marginTop="16dp"
                          android:tag="@string/project_chart_tag"
                          android:visibility="gone"/&gt;
                  &lt;/LinearLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>I added the complete layout, and also here is an image for clarification (I marked the scrollable areas which I can drag):</p>
  
  <p><a href="https://i.stack.imgur.com/tXUdR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tXUdR.png" alt="scrollable areas"></a></p>
  
  <p><strong>EDIT2</strong></p>
  
  <p>Maybe it is also important that these layouts are Fragments inside a <code>ViewPager</code>. Is it possible that the <code>ViewPager</code> prevents the <code>ScrollView</code> (and any other views inside it) gaining the focus / handling the touch events? The code for my <code>ViewPager</code> is this:</p>
  
  <pre><code>&lt;android.support.v4.view.ViewPager
      android:id="@+id/projectPager"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"/&gt;
  </code></pre>
  
  <p><strong>EDIT3</strong></p>
  
  <p>It seems the problem must be with <code>ViewPager</code> + <code>(Nested)ScrollView</code> (I tried to exchange the plain <code>ScrollView</code> with that, but without success). I created a dummy layout for my Fragment that only hosts a parent <code>NestedScrollView</code>, a <code>LinearLayout</code> and many big <code>TextView</code>s like this:</p>
  
  <pre><code>&lt;android.support.v4.widget.NestedScrollView
  android:id="@+id/scrollView"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:card_view="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".projects.details.ProjectDetailsActivity_"&gt;
  
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:padding="@dimen/activity_horizontal_margin"&gt;
  
      &lt;TextView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginBottom="16dp"
          android:ellipsize="none"
          android:gravity="center_horizontal"
          android:text="Project name"
          android:textSize="80sp"/&gt;
  
  ... &lt;!-- more TextViews come here --&gt;
  </code></pre>
  
  <p>...and scrolling also doesn't work! Only at the very edge of the screen, as previously. I have no idea how can this happen...</p>