久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

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

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

瀏覽:117日期: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文件中格式化代碼后,控件的順序都變了,這不是我們想要的結果,網(wǎng)上搜了一下,確實是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='點擊按鈕獲取網(wǎng)絡數(shù)據(jù)' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數(shù)據(jù)【成功】' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數(shù)據(jù)【失敗】' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數(shù)據(jù)【異常】' /></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='獲取數(shù)據(jù)【成功】' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數(shù)據(jù)【失敗】' /> <Button android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='獲取數(shù)據(jù)【異常】' /> <TextView android: android:layout_width='match_parent' android:layout_height='0dp' android:layout_weight='1' android:text='點擊按鈕獲取網(wǎng)絡數(shù)據(jù)' /></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的解決就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。

標簽: Android
相關文章:
主站蜘蛛池模板: 丁香亚洲| 欧美国产视频一区 | 成人午夜免费视频 | 亚洲精品中文字幕中文字幕 | 亚洲欧美精品一区二区三区 | 日韩成人免费在线 | 亚洲福利 | 亚洲精品一区二区三区蜜桃久 | 日韩在线精品视频 | 久久亚洲精品视频 | 日韩精品一区二区在线观看 | 5060毛片 | 在线视频成人永久免费 | 天天狠狠操 | 久久精品国产99国产精品 | 一区二区三区视频免费在线观看 | 一区二区在线看 | 久久国产一区视频 | 亚洲毛片网| 做视频免费观看网站 | 亚洲电影在线 | 国产成人精品一区二区三区视频 | 日韩色图在线观看 | 久久黄色网 | 禁果av一区二区三区 | 精品日本久久 | 久久精品不卡 | 日韩欧美成人一区二区三区 | 国产情侣一区二区三区 | 国产精品99久久久久久久久久久久 | 欧美日韩二区三区 | 精品一区二区在线观看 | 久久久精品久久久久久 | 亚洲精品成人av | 日韩一区精品视频 | 欧美怡红院视频一区二区三区 | 成人婷婷| 韩国精品主播一区二区在线观看 | 午夜不卡视频 | 国产欧美一区二区视频 | 欧美亚洲国产一区 |