I have a dialog with a layout inside and a SurfaceTexture with a video stream. When I get the width and height from the video, I resize my layout as follows:
private void resizeView(final VideoFormatInfo info) { final Size size = calculateSize(info.getWidth(), info.getHeight()); mActivity.runOnUiThread(new Runnable() { @Override public void run() { final ViewGroup.LayoutParams layoutParams = mInnerLayout.getLayoutParams(); layoutParams.width = size.x; layoutParams.height = size.y; Log.i(TAG, String.format("run: setting innerlayout bounds to %d,%d", size.x, size.y)); mInnerLayout.setLayoutParams(layoutParams); } }); }
Now I have a full-screen button that should resize the layout to full screen. But when I click it, the layout remains in a small area of the screen.
When I check the log, the correct value on size.x and size.y is (screen borders), but the layout does not change properly.
The internal output is added to the customView named "VideoPlayer". I set the background color of the video player to red, so when I switch to full screen mode, the entire screen turns red, except for the video stream in the middle. This means that the main view is correctly changed, but innerLayout is not for any reason.
Funny, I have another layout over video rendering that creates a “flash effect” to simulate a camera flash when taking a picture. When this flash effect is triggered, the video changes to full screen.
So this is my layout tree:
VideoPlayerView (CustomView, not VideoView) innerLayout (RelativeLayout) videoSurfaceTexture (SurfaceTextureView) flashLayout (RelativeLayout)
I also set this for debugging:
@Override public void onSurfaceTextureSizeChanged(final SurfaceTexture surfaceTexture, final int width, final int height) { Log.d(TAG, "onSurfaceTextureSizeChanged size=" + width + "x" + height + ", st=" + surfaceTexture); Log.i(TAG, String.format("innerlayout bounds are %d,%d", mInnerLayout.getLayoutParams().width, mInnerLayout.getLayoutParams().height)); }
The values in the internal layout are the correct values (of the entire screen) when you click on full-screen mode, but the layout does not change. I can say that the layout was not changed because I changed its background color to green and added some addition, and I see it in the center of the screen, taking up a small space.
It seems that the view does not update with a layout change.
I'm running out of ideas here. I tried invalidate() , postInvalidate() and forceLayout() , but they do not work.