android 动画错位,Android Studio 3.5格式化布局代码时错位、错乱bug的解决

更新到3.5版本后,格式化布局文件代码,会自动给排序元素,导致界面布局错乱

解决办法:

设置 > code style > XML 右上角 Set from然后选择Predefined Style...>Android即可

71a054e16926fa5ec21841690f8f7597.png

补充知识:Android Studio:Reformat Code格式化Xml布局代码后控件顺序错乱

Android Studio升级3.5之后,遇到个奇葩问题,在布局xml文件中格式化代码后,控件的顺序都变了,这不是我们想要的结果,网上搜了一下,确实是AS3.5的锅,每次升级都会遇到不同的问题,先记录一下吧,以后有时间再研究为什么做的调整。

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:padding="16dp"

tools:context="sun.geoffery.mvpdemo.MainActivity">

android:id="@+id/text"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:text="点击按钮获取网络数据" />

android:id="@+id/getData"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="获取数据【成功】" />

android:id="@+id/getDataForFailure"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="获取数据【失败】" />

android:id="@+id/getDataForError"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="获取数据【异常】" />

这个简单的布局界面大致如下图所示:

be9e76664c56c6fc86cdf4511f5df11e.png

走你,Ctrl+Shift+F,格式化一把,再看我们的代码:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:padding="16dp"

tools:context="sun.geoffery.mvpdemo.MainActivity">

android:id="@+id/getData"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="获取数据【成功】" />

android:id="@+id/getDataForFailure"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="获取数据【失败】" />

android:id="@+id/getDataForError"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="获取数据【异常】" />

android:id="@+id/text"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:text="点击按钮获取网络数据" />

原本最顶部的TextView被格式化到了最下面,一脸懵逼,界面如下:

ccccb91987547f093af221e50edeaaa9.png

具体解决方法如下:

Settings–>Editor–> Code Style–>XML

点击右上角的Set from->Predefined Style选择Android后点击OK保存,Perfect!

65d5ecb022f089f104f958715bd754fb.png

再格式化代码,就是我们想要的效果了

54a18f1716921383d99b39bb127c9be2.png

以上这篇Android Studio 3.5格式化布局代码时错位、错乱bug的解决就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值