I am trying to implement pip mode in android. There is a LiveStreamActivity which contains these elements: Header layout, VideoStream layout and custom popup that I show programatically. Their contexts are the same: LiveStreamActivity. When I enter pip mode LiveStreamActivity's root layout shrinks and fits in small pip screen. But I only want to show VideoStream layout.
I tried setSourceRectHint
to achieve this but it does not work. Summary : How to show desired view (or views) in pip mode?
override fun onUserLeaveHint() {
val visibleRect = Rect()
mBinding.videoStreamLayout.getGlobalVisibleRect(visibleRect)
enterPictureInPictureMode(PictureInPictureParams.Builder()
.setAspectRatio(Rational(9,16))
.setAutoEnterEnabled(true)
.setSourceRectHint(visibleRect)
.setSeamlessResizeEnabled(false)
.build())
super.onUserLeaveHint()
}