title: How can I force the requestLayout() when even forceLayout() doesn't work?
body: <p>I am trying to code a video player, It play the video well but I can't resize the SurfaceView.
  When the MediaPlayer is prepared, I set the size I want and I call requestLayout or forceLayout, but nothing appends. My LogCat say :</p>
  
  <pre><code>08-29 17:42:38.915: I/SEC_Overlay(2707): overlay_setParameter param[4]=0
  08-29 17:42:38.915: D/SEC_Overlay(2707): dst width, height have changed [w= 480, h= 800] -&gt; [w=480, h= 800]
  08-29 17:42:38.915: I/SEC_Overlay(2707): Nothing to do!
  </code></pre>
  
  <p>It obviously try to resize but it found that nothing change and doesn't call onMesured or onLayout</p>
  
  <p>My code :</p>
  
  <pre><code>public class VideoSurface extends ViewGroup {
  private final String TAG = "VideoSurface";
  protected  int mWidth = 0 ;
  protected  int mHeight = 0 ;
  protected SurfaceView mSurfaceView;
  protected SurfaceHolder mHolder;
  
  public VideoSurface(Context context) {
      super(context);
      init(context);
  }
  public VideoSurface(Context context, AttributeSet attrs) {
      super(context,attrs);
      init(context);
  }
  public VideoSurface(Context context, AttributeSet attrs, int defStyle) {
      super(context,attrs,defStyle);
      init(context);
  }
  
  
  private void init(Context context){
      // Install a SurfaceHolder.Callback so we get notified when the
      // underlying surface is created and destroyed.
      mSurfaceView = new SurfaceView(context);
      this.addView(mSurfaceView);
  
      // Install a SurfaceHolder.Callback so we get notified when the
      // underlying surface is created and destroyed.
      mHolder=mSurfaceView.getHolder() ;
      mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  }
  
  public Surface getSurface(){return mHolder.getSurface();}
  public void setSize(Size size){
      mWidth = size.width ;
      mHeight = size.height ;
  }
  public void setSize(int w,int h){
      mWidth = w ;
      mHeight = h ;
  }
  
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      // We purposely disregard child measurements because act as a
      // wrapper to a SurfaceView that centers the camera preview instead
      // of stretching it.
      final int width = resolveSize(getSuggestedMinimumWidth(), widthMeasureSpec);
      final int height = resolveSize(getSuggestedMinimumHeight(), heightMeasureSpec);
      setMeasuredDimension(width, height);
      Log.d(TAG,"onMeasure:"+width+"x"+height);
  }
  
  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
      if (changed &amp;&amp; getChildCount() &gt; 0) {
          final View child = getChildAt(0);
  
          final int width = r - l;
          final int height = b - t;
  
          int previewWidth = width;
          int previewHeight = height;
          if ((mWidth != 0)&amp;&amp;(mHeight != 0)) {
              previewWidth = mWidth;
              previewHeight = mHeight;
          }
          Log.d(TAG,"onLayout L1: Desired:"+mWidth+"x"+mHeight+" Actual:"+previewWidth+"x"+previewHeight);
  
          // Center the child SurfaceView within the parent.
          if (width * previewHeight &gt; height * previewWidth) {
              final int scaledChildWidth = previewWidth * height / previewHeight;
              child.layout((width - scaledChildWidth) / 2, 0,
                      (width + scaledChildWidth) / 2, height);
          } else {
              final int scaledChildHeight = previewHeight * width / previewWidth;
              child.layout(0, (height - scaledChildHeight) / 2,
                      width, (height + scaledChildHeight) / 2);
          }
      }
      Log.d(TAG,"onLayout L2:"+l+", "+t+", "+r+", "+b);
  }
  </code></pre>
  
  <p>And the herited class :</p>
  
  <pre><code>public class PlayerView extends VideoSurface implements SurfaceHolder.Callback {
  private static final String TAG = "PlayerView";
  private MediaPlayer mPlayer = new MediaPlayer() ;
  private String mVideoPath = "" ;
  
  public PlayerView(Context context) {
      super(context);
      init();
  }
  public PlayerView(Context context, AttributeSet attrs) {
      super(context,attrs);
      init();
  }
  public PlayerView(Context context, AttributeSet attrs, int defStyle) {
      super(context,attrs,defStyle);
      init();
  }
  
  private void init(){
      mHolder.addCallback(this);
  
      mPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener(){
          @Override
          public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
              //TODO
              mHolder.setFixedSize(width,height);
              setSize(width,height) ;
              setLayoutParams(new LayoutParams(width, height));
              requestLayout() ;
              forceLayout();
              Log.d(TAG,"Size:"+width+"x"+height);
          }
      });
      mPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
          @Override
          public void onPrepared(MediaPlayer mp) {
              // TODO 
              setSize(mPlayer.getVideoWidth(), mPlayer.getVideoHeight());
              mPlayer.start();
              Log.d(TAG,"Started");
          }
      });
  
      //TODO DEBUG
      mVideoPath = Environment.getExternalStorageDirectory().getPath()+"/external_sd/USB Storage/test.mp4" ;
  }
  
  private void prepareVideo(String path){
      stop() ;
      try {
          mPlayer.setDataSource(path) ;
      } catch (IllegalArgumentException e) {
          e.printStackTrace();
      } catch (IllegalStateException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      //TODO
      //mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
  
      mPlayer.prepareAsync() ;
  }
  
  public void start(String path) {
      mVideoPath = path ;
      if (!mHolder.isCreating()){
          prepareVideo(path) ;
      }
  }
  
  public void stop() {
      if (mPlayer.isPlaying()) {
          mPlayer.stop();
      }
      mPlayer.reset();
  }
  
  public void onStop(){
      stop() ;
      mPlayer.release();
  }
  
  @Override
  public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
  
  @Override
  public void surfaceCreated(SurfaceHolder holder) {
      mPlayer.setDisplay(mHolder);
      if(!mVideoPath.isEmpty()){
          prepareVideo(mVideoPath) ;
      }
  }
  
  @Override
  public void surfaceDestroyed(SurfaceHolder holder) {
  }
  </code></pre>
  
  <p>}</p>
  
  <p>How can I force the requestLayout() when even forceLayout() doesn't work ?</p>