android 需要ConstraintLayout下面的 b 视图向下平移隐藏但是 b视图已经toBottomOf=parent 了
您可以使用以下方法将b视图向下平移隐藏:
-
在b视图的父级ConstraintLayout中添加一个空白的View,将其命名为“spacer”。
-
将b视图的顶部边缘与“spacer”的底部边缘对齐。
-
将“spacer”的底部边缘与父级ConstraintLayout的底部边缘对齐。
-
在代码中,使用以下代码将“spacer”向下平移隐藏:
View spacer = findViewById(R.id.spacer);
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) spacer.getLayoutParams();
params.bottomMargin = -spacer.getHeight();
spacer.setLayoutParams(params);
这将使“spacer”向下平移,同时将b视图也向下平移,从而隐藏它。
原文地址: https://www.cveoy.top/t/topic/dnUV 著作权归作者所有。请勿转载和采集!