亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

Android Studio 3.5格式化布局代碼時錯位、錯亂bug的解決

瀏覽:101日期:2022-09-26 14:30:58

更新到3.5版本后,格式化布局文件代碼,會自動給排序元素,導致界面布局錯亂

解決辦法:

設置 > code style > XML 右上角 Set from然后選擇Predefined Style...>Android即可

Android Studio 3.5格式化布局代碼時錯位、錯亂bug的解決

補充知識:Android Studio:Reformat Code格式化Xml布局代碼后控件順序錯亂

Android Studio升級3.5之后,遇到個奇葩問題,在布局xml文件中格式化代碼后,控件的順序都變了,這不是我們想要的結果,網上搜了一下,確實是AS3.5的鍋,每次升級都會遇到不同的問題,先記錄一下吧,以后有時間再研究為什么做的調整。

<?xml version='1.0' encoding='utf-8'?><LinearLayout xmlns:android='http://schemas.android.com/apk/res/android' 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'> <TextView android: android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:text='點擊按鈕獲取網絡數據' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數據【成功】' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數據【失敗】' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數據【異常】' /></LinearLayout>

這個簡單的布局界面大致如下圖所示:

Android Studio 3.5格式化布局代碼時錯位、錯亂bug的解決

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

<?xml version='1.0' encoding='utf-8'?><LinearLayout xmlns:android='http://schemas.android.com/apk/res/android' 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'> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數據【成功】' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數據【失敗】' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數據【異常】' /> <TextView android: android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:text='點擊按鈕獲取網絡數據' /></LinearLayout>

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

Android Studio 3.5格式化布局代碼時錯位、錯亂bug的解決

具體解決方法如下:

Settings?>Editor?> Code Style?>XML

點擊右上角的Set from->Predefined Style選擇Android后點擊OK保存,Perfect!

Android Studio 3.5格式化布局代碼時錯位、錯亂bug的解決

再格式化代碼,就是我們想要的效果了

Android Studio 3.5格式化布局代碼時錯位、錯亂bug的解決

以上這篇Android Studio 3.5格式化布局代碼時錯位、錯亂bug的解決就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Android
相關文章:
主站蜘蛛池模板: 色婷婷色99国产综合精品 | 高清国产一级精品毛片基地 | 中文字幕在线观看一区二区 | 97国产在线视频 | 中文字幕不卡一区 二区三区 | a国产成人免费视频 | 国产日产精品久久久久快鸭 | 亚洲一区二区精品 | 精品国产免费一区二区 | 三级黄色片免费观看 | 国产超级碰碰在线公开视频 | 亚洲国产日韩在线观频 | 国产女同磨豆腐视频在线观看 | 1024手机在线观看视频 | 日本免费一区二区三区a区 日本内谢69xxxx免费播放 | 欧美日本一级在线播放 | 精品一区二区在线观看 | 一级毛片在线全部免费播放 | 91麻豆视频 | 久久久免费视频播放 | 久久国产欧美日韩精品免费 | 日本在线观看免费看片 | 特黄特色一级aa毛片免费观看 | 国产69精品久久久久9999 | 黄色一级一毛片 | 国产日韩欧美在线一区二区三区 | 国产在线观看福利一区二区 | 国产片在线 | 午夜在线亚洲 | 精品久久洲久久久久护士 | 最近最新中文字幕在线第一页 | 一区二区三区网站 | 黑人巨大两根一起挤进来 | aaa一级毛片 | 日韩在线第一区 | 中国xxxx视频播放 | 国产人妖在线观看一区二区 | 青青热久久综合网伊人 | 在线精品国内外视频 | 色婷婷中文字幕 | 黄色片在线免费观看视频 |