title: scrollable view in a fragment
body: <p>I've been stuck on this for a few days now and can't figure out what I'm doing wrong (hope it's not something stupid I missed).</p>
  
  <p><strong>The requirements</strong></p>
  
  <p>I have a FragmentPager which contains Fragments with LinearLayout. The layout has a button and a view that can change according to user navigation.</p>
  
  <p>All views such as GridView and ListView work perfectly. But I need to make another view that would fit in the Fragment that is a little different in concept. The view must be vertically scrollable since it's height can get bigger than the screen size. I don't care if the view is created programatically or inflated from .xml dynamically. I tried both methods and both gave the same results.</p>
  
  <p><strong>Solution 1 (much more preferable)</strong></p>
  
  <p>I tried to make a custom view and pushed it inside a ScrollView. This is the relevant .xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/scroller"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:fillViewport="true" &gt;
      &lt;com.myPackage.MyView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content" &gt;
  &lt;/com.myPackage.MyView&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>I made the custom view to show a really large rectangle so it exceeds screen size.
   code for MyView:</p>
  
  <pre><code>package com.myPackage.MyView;
  
  import android.content.Context;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.util.AttributeSet;
  import android.view.View;
  
  public class MyView extends View {
      public MyView(Context context) {
          super(context);
      }
  
      public MyView(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      @Override
      protected void onDraw(Canvas canvas) {
          Paint paint = new Paint();
          paint.setColor(Color.RED);
          canvas.drawRect(0, 0, 100, 8000, paint);
      }
  }
  </code></pre>
  
  <p>The problem with this is that the ScorllView doesn't scroll.</p>
  
  <p>I tried removing the fillViewport (as I saw in a different answer) which resulted in nothing shown at all,
  I also tried to add layouts inside and outside the ScrollView but nothing. Trying all the "fill_parent"/"wrap_content" combinations also resulted with non-scrolling ScrollView.</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>Solution 2 (much less preferable)</strong></p>
  
  <p>I can force (brutally) the concept of the view into a ListView, which does scroll fine but I couldn't get the views inside the list to display my custom view. Debugging, I noticed that onDraw is never called. Do I need to implement the drawing of the view somewhere else so it will be drawn in a ListView?</p>