该视图不受限制,它仅具有设计时位置,因此除非您添加约束,否则它将跳至(0,0). [英] This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints The
问题描述
此视图不受约束,它仅具有设计时位置,因此除非添加约束,否则它将跳到(0,0).
This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints.
布局编辑器允许您将小部件放置在画布上的任何位置,并使用designtime属性(例如layout_editor_absoluteX)记录当前位置.这些属性在运行时不会应用,因此,如果将布局推送到设备上,小部件可能出现在与编辑器中不同的位置.要解决此问题,请通过从边缘连接处拖动来确保小部件同时具有水平和垂直约束.
The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with designtime attributes (such as layout_editor_absoluteX.) These attributes are not applied at runtime, so if you push your layout on a device, the widgets may appear in a different location than shown in the editor. To fix this, make sure a widget has both horizontal and vertical constraints by dragging from the edge connections.
推荐答案
这可能会对某人有所帮助. 我正在使用Android Studio 3.1,并且遇到相同的问题,但是我没有找到上述答案中建议的这些选项(约束布局->推断布局). 然后,在仔细检查之后,我在布局窗口上方找到了推断约束"选项(请参阅下面的步骤1中的屏幕截图)
This may help someone. I am using Android Studio 3.1 and i faced same problem but i didn't find these options (Constraint Layout -> Infer Layout) as suggested in the above answer. Then after carefully checking i found "Infer Constraint" option above the layout window (refer to screenshot below in step 1)
第1步:点击推断约束".这可能可以解决您的问题,但是如果您的小部件仍然不可见(例如我的情况),请执行步骤2.
Step 1: Click on "Infer Constraint". This may solve your problem, but if your widget still not visible (as in my case), then follow step 2.
第2步:点击"AppTheme",然后选择"NoTitleBar"主题,如屏幕截图所示
Step 2: Click on "AppTheme" and select "NoTitleBar" theme as selected in the screenshot
这解决了我的问题.
这篇关于该视图不受限制,它仅具有设计时位置,因此除非您添加约束,否则它将跳至(0,0).的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!