左上角的 ConstraintLayout 视图 [英] ConstraintLayout views in top left corner
问题描述
每次我在 ConstraintLayout
中创建像 Button
和 TextView
这样的视图时,它们都会卡在顶角而不是我放置它们的位置.
我尝试创建新活动并更改模拟器,但结果仍然相同.
这是正在发生的事情的屏幕截图:
可能是什么问题?
如
Every time I create views like Button
and TextView
in ConstraintLayout
, they all get stuck at the top corner instead of where I placed them.
I tried to create new activities and change the emulator, but the result is still the same.
This is a screenshot of what's happening:
What may be the issue?
As stated in Constraint Layout guides:
If a view has no constraints when you run your layout on a device, it is drawn at position [0,0] (the top-left corner).
You must add at least one horizontal and one vertical constraint for the view.
I guess you haven't applied any constraints.
Either manually apply constraints to the view, or let the layout editor do it for you using "Infer constraints" button:
这篇关于左上角的 ConstraintLayout 视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!