是否可以在layout_constraintend_toendof ='parent; quord之间转换。和layout_constraintend_tostartof =&quot@id/img;根据特定条件

发布于 2025-01-22 06:36:51 字数 711 浏览 0 评论 0原文

我将其绘制而不是XML,因此您可以理解我想要的

“在此处输入图像说明”

如果image> ImageView不是对面屏幕1然后我要应用此app:layout_constraint_toendof =“ parent”内部 chipgroup ,否则请应用此app:layout_constraut_taintend_tostartof =“ @ID/imgview“

可以使用barrier指南,还是其他任何东西?

我以前发表了这个问题,但没有引起任何关注,是否可以在Android中这样做?我搜索了很多东西来找到类似的问题,但我什么也没找到。

上图中的所有组件都在CondectaintLayout中。

每个imageView具有不同的高度,因此某些图像将是 比其他人最高。

I drew this instead of XML so you can understand what I want

enter image description here

If the ImageView was not opposite ChipGroup like Screen 1 then I want to apply this app:layout_constraintEnd_toEndOf="parent" inside ChipGroup, Otherwise apply this app:layout_constraintEnd_toStartOf="@id/imgView"

Is it possible to do it using Barrier, Guideline, or anything else?

I published the question before but does not take any attention, Is it possible to do that in Android? I searched a lot to find similar questions but I did not find anything.

All components in the image above are inside ConstraintLayout.

Every ImageView has a different height, So some images will be
tallest than others.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘落散花 2025-01-29 06:36:51

可以使用CondraintSet进行程序更改View的约束,

以设置chipgroup结束至parent> parent结束

val parent = findViewById<ConstraintLayout>(R.id.parent) // constraint layout
val constraintSet = ConstraintSet()
constraintSet.clone(parent)
constraintSet.apply {
    clear(R.id.chipGroup, ConstraintSet.END)
    connect(R.id.chipGroup, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END)
    applyTo(parent)
}

到设置<代码> chipgroup 结束至imageView开始

val parent = findViewById<ConstraintLayout>(R.id.parent) // constraint layout
val constraintSet = ConstraintSet()
constraintSet.clone(parent)
constraintSet.apply {
    clear(R.id.chipGroup, ConstraintSet.END)
    connect(R.id.chipGroup, ConstraintSet.END, R.id.imgView, ConstraintSet.START)
    applyTo(parent)
}

The constraint of a view can be changed programatically, using constraintSet

To set chipGroup end to parent end

val parent = findViewById<ConstraintLayout>(R.id.parent) // constraint layout
val constraintSet = ConstraintSet()
constraintSet.clone(parent)
constraintSet.apply {
    clear(R.id.chipGroup, ConstraintSet.END)
    connect(R.id.chipGroup, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END)
    applyTo(parent)
}

To set chipGroup end to imageView start

val parent = findViewById<ConstraintLayout>(R.id.parent) // constraint layout
val constraintSet = ConstraintSet()
constraintSet.clone(parent)
constraintSet.apply {
    clear(R.id.chipGroup, ConstraintSet.END)
    connect(R.id.chipGroup, ConstraintSet.END, R.id.imgView, ConstraintSet.START)
    applyTo(parent)
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文