title: Resize ScrollView viewport after childView.setScaleX()/setScaleY()
body: <p>I have a problem with a TwoDScrollView layout. After scaling its child, vertical and horizontal scroll ranges of TwoDScrollView remain unchanged.</p>
  
  <p>This is the XML code:</p>
  
  <pre><code>&lt;com.fine.example.TwoDScrollView      
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/scrolling"
      android:drawingCacheQuality="low"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;RelativeLayout
          android:id="@+id/board"
          android:clipChildren="false"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:drawingCacheQuality="low"
          android:layout_marginTop="?android:attr/actionBarSize"
          android:layout_marginBottom="?android:attr/actionBarSize"
          android:paddingTop="@dimen/padmargsmedium"
          android:paddingBottom="?android:attr/actionBarSize"
          android:paddingLeft="@dimen/padmarg"
          android:paddingRight="@dimen/padmarg" &gt;
  
          &lt;RelativeLayout
              android:id="@+id/boardf"
              android:drawingCacheQuality="low"
              android:layout_width="match_parent"
              android:layout_height="match_parent" &gt;
  
          &lt;/RelativeLayout&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;/com.fine.example.TwoDScrollView&gt;
  </code></pre>
  
  <p>And this is how I scale the childView:</p>
  
  <pre><code>scale -= 0.25f;      // or scale += 0.25f;
  board.setPivotX(0.5f/scale);
  board.setPivotY(0.5f/scale);
  board.setScaleX(1f/scale);
  board.setScaleY(1f/scale);
  </code></pre>
  
  <p>Actually I managed to fix the "zoom in" by doing this:</p>
  
  <pre><code>TwoDScrollView.LayoutParams params = (TwoDScrollView.LayoutParams) board.getLayoutParams();
  params.width = (int) (xwidth/scale);
  params.height = (int) (yheight/scale);
  board.setLayoutParams(params);
  </code></pre>
  
  <p>But for the "zoom out" the same code doesn't work. Size of the child changes, but ScrollView doesn't update its container size, scrolling way more than what it's needed while showing an empty space between the scrollview and its scaled child.</p>
  
  <p>You can find the TwoDScrollView source (by Matt Clark) here:</p>
  
  <p><a href="https://web.archive.org/web/20121125032032/http://blog.gorges.us/2010/06/android-two-dimensional-scrollview/comment-page-1/#comments" rel="nofollow noreferrer">https://web.archive.org/web/20121125032032/http://blog.gorges.us/2010/06/android-two-dimensional-scrollview/comment-page-1/#comments</a></p>
  
  <p>Things I've tried:</p>
  
  <ul>
  <li><p>Replacing the TwoDScrollView for a ScrollView and setting fillViewPort="true", but the same happens.</p></li>
  <li><p>Changing layout_width and layout_height to WRAP_CONTENT or MATCH_PARENT in both layouts and every possible combination.</p></li>
  <li><p>Same with invalidate() and requestLayout().</p></li>
  <li><p>Setting Visibility to GONE and then to VISIBLE, like explained here: <a href="https://stackoverflow.com/questions/15572336/scrollview-does-not-resize-directly-after-child-changes">ScrollView does not resize directly after child changes</a>.</p></li>
  <li><p>I even tried to force scale in these TwoDScrollView methods: computeVerticalScrollRange, computeHorizontalScrollRange, measureChild, measureChildWithMargins and computeScroll, but with no results.</p></li>
  <li><p>Searching stackoverflow: there are some questions like mine, but when there's an answer, sadly it does not work for me.</p></li>
  </ul>
  
  <p>How can I fix this? Any help would be really appreciated!</p>