android ConstraintLayout不允许负边距 [英] android ConstraintLayout does not allow negative margins

查看:558
本文介绍了android ConstraintLayout不允许负边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相对于布局指南放置了许多物品, 并希望相对于该布局指南定位一个新项目.

I position lots of items relative to a layout guide, and would like to position a new item nearly relative to this layout guide.

我尝试使用负的布局边距,但没有成功.

I tried with a negative layout margin without success.

推荐答案

这是一个博客发布,其中讨论了ConstraintLayout中的负边距.

Here is a blog posting that discusses negative margins in ConstraintLayout.

使用空格作为负边距

ConstraintLayout中的视图的边距不能为负(不支持).但是,通过一个简单的技巧,您可以通过插入一个Space(本质上是一个空View)并将其大小设置为所需的边距来实现类似的功能.

A view in a ConstraintLayout cannot have negative margins (it’s not supported). However, with an easy trick you can have similar functionality by inserting a Space (which is essentially an empty View) and setting its size to the margin you want.

这篇关于android ConstraintLayout不允许负边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆