之前一直使用ADT进行Android开发,但ADT打印不了日志让人非常绝望,于是换了Android studio ,体验和ADT完全不同,连开始最简单的界面控拖动就一直在报错。

问题背景
在ConstraintLayout布局内使用控件时遇到This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints提示,具体信息如下图:
【Android】ConstraintLayout布局中使用控件提示This view is not constrained, it only has designtime positions,...
根据提示信息
This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints
(大概的意思是:这个视图不受约束,它只有设计时位置,所以它会跳转到(0,0),除非你添加约束)我们可以得知这是在提示我们为该控件添加约束。
上网查了之后,说只需要点击ConstrainLayout就能找到那个infer Constraints了,但因为我下载的是最新版本,和博客中介绍的界面完全不同,这是Android studio之前版本此问题的解决方式
【Android】ConstraintLayout布局中使用控件提示This view is not constrained, it only has designtime positions,...
点击一下infer Constraints,就可以手动取消约束
以下是我遇到的问题,也就是AS最新版本的问题,界面中没有上述选项
【Android】ConstraintLayout布局中使用控件提示This view is not constrained, it only has designtime positions,...
最后才知道,ConstrainLayout 不在我右击一个控件的下拉菜单里,而是在设计预览界面上方的工具栏菜单中有一个看起来像魔术棒的图标,那也是一个“infer Constrains”的按钮。
就是图中这个魔术棒,点击之后就可以取消约束了,也不会在报错了。
【Android】ConstraintLayout布局中使用控件提示This view is not constrained, it only has designtime positions,...

相关文章:

  • 2021-12-27
  • 2022-01-22
  • 2021-12-16
  • 2022-01-23
  • 2021-04-14
  • 2022-12-23
  • 2021-10-13
  • 2022-01-19
猜你喜欢
  • 2021-11-30
  • 2022-01-19
  • 2021-05-06
  • 2021-07-28
  • 2021-05-19
  • 2021-10-23
相关资源
相似解决方案