最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2020年03月17日 15:02:14   作者:Q913214983  
這篇文章主要介紹了Android Studio 3.5格式化布局代碼時錯位、錯亂bug的解決,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

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

解決辦法:

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

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

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

<?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:id="@+id/text"
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_weight="1"
  android:text="點擊按鈕獲取網(wǎng)絡數(shù)據(jù)" />

 <Button
  android:id="@+id/getData"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="獲取數(shù)據(jù)【成功】" />

 <Button
  android:id="@+id/getDataForFailure"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="獲取數(shù)據(jù)【失敗】" />

 <Button
  android:id="@+id/getDataForError"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="獲取數(shù)據(jù)【異?!? />

</LinearLayout>

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

走你,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:id="@+id/getData"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="獲取數(shù)據(jù)【成功】" />

 <Button
  android:id="@+id/getDataForFailure"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="獲取數(shù)據(jù)【失敗】" />

 <Button
  android:id="@+id/getDataForError"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="獲取數(shù)據(jù)【異?!? />

 <TextView
  android:id="@+id/text"
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_weight="1"
  android:text="點擊按鈕獲取網(wǎng)絡數(shù)據(jù)" />

</LinearLayout>

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

具體解決方法如下:

Settings–>Editor–> Code Style–>XML

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

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

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

相關(guān)文章

最新評論

榆树市| 八宿县| 甘肃省| 那曲县| 江安县| 禹城市| 孟村| 罗平县| 泰兴市| 敦化市| 巴彦淖尔市| 高尔夫| 长寿区| 原平市| 开化县| 武隆县| 志丹县| 喀喇沁旗| 绿春县| 甘孜| 深水埗区| 黄石市| 南阳市| 息烽县| 鄢陵县| 崇仁县| 石门县| 清流县| 桐城市| 迁安市| 通江县| 丰城市| 深泽县| 吐鲁番市| 大荔县| 通河县| 石楼县| 龙川县| 宁城县| 白河县| 时尚|