左上角的 ConstraintLayout 视图 [英] ConstraintLayout views in top left corner

查看:45
本文介绍了左上角的 ConstraintLayout 视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我在 ConstraintLayout 中创建像 ButtonTextView 这样的视图时,它们都会卡在顶角而不是我放置它们的位置.

我尝试创建新活动并更改模拟器,但结果仍然相同.

这是正在发生的事情的屏幕截图:

可能是什么问题?

解决方案

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屋!

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