Android布局编辑器ConstraintLayout [英] Android Layout editor ConstraintLayout

查看:63
本文介绍了Android布局编辑器ConstraintLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Android Studio(前几天进行了最新的Stabel升级.当我使用布局编辑器时,它似乎更喜欢ConstraintLayout.当我移动两个小部件(一个TextView和一个按钮)时,它在编辑器上看起来正常,但是当我在模拟器设备(Nexus 4)中尝试使用它们时,它们都都位于右上角.在我的真实设备上也是如此.这里是否存在版本问题?

I am running Android Studio (put on latest stabel upgrade the other day. When I use the Layout editor it seems to prefer ConstraintLayout. When I move two widgets (one TextView and one button) around it looks all right on the editor, but when I try to it in an emulator device (Nexus 4) they both ends up in the Upper right corner. Same thing on my real device. Is there some version problem here?

推荐答案

请在此处检查ConstraintLayout:

Please check ConstraintLayout here:

https://developer.android.com/training/constraint-layout/index.html

将视图放到布局编辑器中时,它会留在您离开的位置 即使没有任何限制.但是,这仅仅是为了 编辑更容易;如果在运行布局时视图没有约束 在设备上,它绘制在位置[0,0](左上角).

When you drop a view into the Layout Editor, it stays where you leave it even if it has no constraints. However, this is only to make editing easier; 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).

换句话说,这意味着您必须为视图添加至少一个水平约束和一个垂直约束

In other words, it means you must add at least one horizontal and one vertical constraint for the view

这篇关于Android布局编辑器ConstraintLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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