Skip to content

Commit cbeb332

Browse files
committed
fix SurfaceView visibility state changes
SurfaceView didn't recompute the transparent region when the INVISIBLE state (as opposed to GONE) was involved. Bug: 6467123 Change-Id: I05930bd568a345331840c1ad8d9123ef4904c04f
1 parent dca5fb9 commit cbeb332

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

core/java/android/view/SurfaceView.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,17 @@ protected void onWindowVisibilityChanged(int visibility) {
231231
public void setVisibility(int visibility) {
232232
super.setVisibility(visibility);
233233
mViewVisibility = visibility == VISIBLE;
234-
mRequestedVisible = mWindowVisibility && mViewVisibility;
234+
boolean newRequestedVisible = mWindowVisibility && mViewVisibility;
235+
if (newRequestedVisible != mRequestedVisible) {
236+
// our base class (View) invalidates the layout only when
237+
// we go from/to the GONE state. However, SurfaceView needs
238+
// to request a re-layout when the visibility changes at all.
239+
// This is needed because the transparent region is computed
240+
// as part of the layout phase, and it changes (obviously) when
241+
// the visibility changes.
242+
requestLayout();
243+
}
244+
mRequestedVisible = newRequestedVisible;
235245
updateWindow(false, false);
236246
}
237247

0 commit comments

Comments
 (0)