android - 是否可以将 ConstraintLayout 子项的大小强制为零?

标签 android android-constraintlayout

android:layout_height="0dp" 似乎被解释为 match_constraints

我想以编程方式将 TextView 的高度强制为 0。我想避免执行 textView.setVisibility(GONE) 以避免必须在任何地方定义 goneMargins。

是否可以指定 child 仍然可见但高度为 0?

最佳答案

如果删除底部约束 app:layout_constraintBottom_toBottomOfapp:layout_constraintBottom_toTopOf 从你的 TextView 然后下面应该工作:

binding.your_textview.layoutParams.height = 0
binding.your_textview.requestLayout()

关于android - 是否可以将 ConstraintLayout 子项的大小强制为零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44413300/

相关文章:

android - 'dump' 方法在 android.location.Location 中做了什么,为什么没有文档?

android - 在 android/Xamarin.Android 中单击通知时切换到运行 Activity

android - 如何在 AOSP 项目中包含约束布局库

Android Dialog Fragment RecyclerView 包装内容但基于约束的最大高度?

Android 约束布局 - 将 View 固定到页面底部和另一个 View 下方(而不是介于两者之间)

android - mdpi 图像对于 10 英寸安卓平板电脑来说太小了

android - 按下软键盘中的 "done"按钮时如何失去编辑文本的焦点?

android - 如何避免 Android 中的 GPS 漂移?

安卓约束布局 : How to add a dynamic view one below another

android - 如何让 ConstraintLayout 为 RTL 正常工作?