我在我的活动中使用这样的gridlayout(命名为'tableView')
这是我创建此网格布局的方法:
tableView.removeAllViews()
val items = AppUtil.getListItemsForGroupLayout(layoutCode)
val totalRows = AppUtil.getRowOrColumns(layoutCode)
val totalCols = AppUtil.getRowOrColumns(layoutCode)
tableView.columnCount = totalCols
tableView.rowCount = totalRows
val inflater = LayoutInflater.from(this@CallTabletScreen)
val widthModified = main_layout.width - AppUtil.convertDpToPixel(16, this@CallTabletScreen)
val width = widthModified / totalCols
val height = widthModified * 9 / 16 / totalRows
for (i in 0 until items.size) {
val it = items[i]
val params = GridLayout.LayoutParams()
params.width = (it[0] * width).toInt()
params.height = (it[1] * height).toInt()
params.rowSpec = GridLayout.spec(it[3], it[1], 1f)
params.columnSpec = GridLayout.spec(it[2], it[0], 1f)
val view = inflater.inflate(R.layout.view_tablet_sub, tableView, false)
view.tag = i + 1
tableView.addView(view, params)
initRenderer(view.render, MeetingClient.mRootEglBase.eglBaseContext)
}
}
我的tableView工作良好,即使旋转到横向模式,只有在 pip 模式下有问题
在进入 pip 模式之前,我会计算tableView比率以确保 pip 覆盖我的tableView
val rect = Rect()
tableView.getGlobalVisibleRect(rect)
val rational = Rational(tableView.width, tableView.height)
val params = PictureInPictureParams.Builder().setAspectRatio(rational).setSourceRectHint(rect).build()
if (isSheetExpand() || isSheetCollapse()) {
hideSheet()
}
enterPictureInPictureMode(params)
当onPictureInPictureModeChanged被调用时,我隐藏了 toolBar + videoView 并只显示图像
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration?) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
Log.e(TAG, "onPictureInPictureModeChanged $isInPictureInPictureMode")
toolbar.visibility = if(isInPictureInPictureMode) View.GONE else View.VISIBLE
tableView.children.forEach {
if(it.render.tag != null) {
it.render.visibility = if (isInPictureInPictureMode) View.GONE else View.VISIBLE
it.imgBg.visibility = if (isInPictureInPictureMode) View.VISIBLE else View.GONE
}
}
}
但这是输入 pip 时的结果:
不能正确显示我的tableView,但是当我点击这个 pip 时,它会放大并按我的预期显示结果:
有人可以帮我知道是什么问题吗?提前致谢