- Using bringToFront on the FPV widget for example and also calling clRoot.invalidate()
- Using the cardElevation and elevation setters as well on the mapCard
- Using setZ() и/или settranslationz ()
....
< /code>
Код, который настраивает высоту и динамически ограничения, является следующим: < /p>
private fun handleMapExpansionToggle(isMapExpanded: Boolean) {
with(binding) {
val widgetFPVDims = if (!isMapExpanded) MATCH_PARENT to MATCH_PARENT else 400 to 212
val mapCardDims = if (!isMapExpanded) 160 to 86 else MATCH_PARENT to MATCH_PARENT
val displayDensityFactor: Float =
requireContext().resources.displayMetrics.density // used to convert pixels to dp
widgetFPV.reset()
// scale down camera surface
widgetFPV.setup(width = widgetFPVDims.first, height = widgetFPVDims.second)
// scale down/up fpv widget
widgetFPV.layoutParams =
ConstraintLayout.LayoutParams(widgetFPVDims.first, widgetFPVDims.second)
widgetFPV.translationZ = if (!isMapExpanded) 0f else 30f
widgetFPV.updateLayoutParams {
startToStart = clRoot.id
bottomToBottom = clRoot.id
if (!isMapExpanded) {
endToEnd = clRoot.id
topToTop = clRoot.id
}
marginStart = if (!isMapExpanded) 0 else 12
bottomMargin = if (!isMapExpanded) 0 else 12
}
// scale up/down map
val mapLayoutParams =
ConstraintLayout.LayoutParams(
(mapCardDims.first * displayDensityFactor).toInt(),
(mapCardDims.second * displayDensityFactor).toInt()
)
mapLayoutParams.setMargins(
if (!isMapExpanded) 12 else 0, 0, 0, if (!isMapExpanded) 12 else 0
)
mapCard.layoutParams = mapLayoutParams
mapCard.elevation = if (!isMapExpanded) 21f else 0f
mapCard.cardElevation = if (!isMapExpanded) 21f else 0f
map.translationZ = if (!isMapExpanded) 21f else 0f
mapCard.translationZ = if (!isMapExpanded) 21f else 0f
mapCard.radius = if (!isMapExpanded) 8f else 0f
mapCard.updateLayoutParams {
startToStart = clRoot.id
bottomToBottom = clRoot.id
if (isMapExpanded) {
endToEnd = clRoot.id
topToTop = clRoot.id
}
marginStart = if (!isMapExpanded) 12 else 0
bottomMargin = if (!isMapExpanded) 12 else 0
}
if (isMapExpanded) {
mapCard.setPadding(0, 12, 0, 0)
}
// update telemetry widget constraints
widgetTelemetry.updateLayoutParams {
startToEnd = if (isMapExpanded) {
widgetFPV.id
} else {
mapCard.id
}
}
llCamera.isVisible = !isMapExpanded
llPhotoVideo.isVisible = !isMapExpanded
widgetLightsControl.isVisible = !isMapExpanded
imgBtnMapLayers.isVisible = isMapExpanded
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... ing-a-came
Мобильная версия