title: How to change the size of a window's surface?
body: <p>So I know that a <code>SurfaceView</code>'s surface size can be changed by calling <code>setFixedSize()</code> on the <code>SurfaceHolder</code>, but when I try to do the same thing on an arbitrary window, one obtained from an activity, I cannot. Here's the relevant test code:</p>
  <pre><code>public class TestActivity extends Activity implements Callback2 {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          getWindow().takeSurface(this);
      }
  
      @Override
      public void surfaceCreated(SurfaceHolder arg0) {
          // TODO Auto-generated method stub
          arg0.setFixedSize(300, 300);
      }
  }
  </code></pre>
  <p>This results in the following error log:</p>
  <blockquote>
  <p>01-15 23:21:46.111: E/AndroidRuntime(9748): FATAL EXCEPTION: main</p>
  <p>01-15 23:21:46.111: E/AndroidRuntime(9748): Process: com.example.windowtest, PID: 9748</p>
  <p>01-15 23:21:46.111: E/AndroidRuntime(9748): java.lang.UnsupportedOperationException: <strong>Currently only support sizing from layout</strong></p>
  <p>01-15 23:21:46.111: E/AndroidRuntime(9748): at android.view.ViewRootImpl$TakenSurfaceHolder.setFixedSize(ViewRootImpl.java:6094)</p>
  </blockquote>
  <p>Where by layout I suppose it means <code>WindowManager.LayoutParams</code> which would resize the Window's dimension as well. So is there no way to change the size of a Window's Surface without changing the Window's dimensions? I would think there is, since we can do it with <code>SurfaceView</code>, but I'm not sure how.</p>
  <p><strong>Edit</strong>: In addition, the <code>SurfaceView</code> <code>setFixedSize()</code> call results in a <code>requestLayout()</code>, which propagates up to an object that implements the <code>ViewParent</code> interface. What is this <code>ViewParent</code> object that is getting attached to the <code>SurfaceView</code> at runtime? Maybe then the logic behind how the surface buffer is getting resized will be clear.</p>