LZ-Says:人呐,最可怕的便是,突然某天转身,却发现曾经以为的熟悉,却是那么陌生。

今天撸码的时候,突然发现格式化 XML 不管用了,而不格式化看的很湿别扭:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto"><android.support.constraint.ConstraintLayoutandroid:layout_width="match_parent" android:padding="15dp"android:layout_height="match_parent"tools:context=".moudle.MainActivity"><Button android:id="@+id/btn_baidu"android:layout_width="match_parent" android:layout_height="wrap_content"android:text="百度地图基本操作"/><Button android:layout_width="match_parent"app:layout_constraintTop_toBottomOf="@id/btn_baidu"android:id="@+id/btn_google"android:textAllCaps="false" android:layout_height="wrap_content" android:text="Google Map"/></android.support.constraint.ConstraintLayout>
</layout>

找了半天,才发现 Android Studio 默认提供一套标准,我们只需要打开即可,如下图所示:

这里需要注意俩点:

  • Scheme 选择 Default 即可(当然也可以自己设置);

  • 记得勾选 “Use custom formatting settings for Android XML files”。

快捷键:option + command + L,格式化效果如下:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"xmlns:app="http://schemas.android.com/apk/res-auto"><android.support.constraint.ConstraintLayoutandroid:layout_width="match_parent"android:padding="15dp"android:layout_height="match_parent"tools:context=".moudle.MainActivity"><Buttonandroid:id="@+id/btn_baidu"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="百度地图基本操作"/><Buttonandroid:layout_width="match_parent"app:layout_constraintTop_toBottomOf="@id/btn_baidu"android:id="@+id/btn_google"android:textAllCaps="false"android:layout_height="wrap_content"android:text="Google Map"/></android.support.constraint.ConstraintLayout>
</layout>

瞬间感觉爽了很多,有木有~

当然,动手能力强的小伙伴可以选择 Arrangement 自己手动添加规则:

个人公众号

不定期发布博文,最近有点忙,感谢老铁理解,欢迎关注~

强迫症 之 Android Studio 格式化 XML相关推荐

  1. Android Studio在xml文件中编写代码时,关键词没有代码提示补全

    问题描述: Android Studio在xml文件中编写代码时,无法自动补全 例如在TextView中输入textSize,没有出现任何代码提示 解决方式: File->Project Str ...

  2. Android Studio中xml文件添加注释

    1 xml文件 xml是Extensible Markup Language即可扩展标记语言的缩写.xml文件就是用xml语言编写的文件,用来存储数据.携带数据和交换数据.Android Studio ...

  3. Android Studio maven-metadata.xml 卡着不动原因和解决方法

    头一天好好的,第二天就卡着了. 一直在这个地方不动,如果停止就会报  Error:Could not run build action using Gradle distribution 'https ...

  4. Android studio 写xml的不能自动补全的问题

    在Build.glide文件下,将ComplieSdk 改为 31 (或更低,未尝试),再sync,即可 android {compileSdk 31defaultConfig {applicatio ...

  5. android 矢量图形文件,Android Studio进行APP设计开发之矢量图及XML文件转换

    Android Studio进行APP设计开发之矢量图及XML文件转换 当我们使用Android studio进行APP设计开发时,会用到矢量图,那么要将矢量图运用到安卓工程drawable中去,就需 ...

  6. Android Studio进行APP设计开发之矢量图及XML文件转换

    Android Studio进行APP设计开发之矢量图及XML文件转换 当我们使用Android studio进行APP设计开发时,会用到矢量图,那么要将矢量图运用到安卓工程drawable中去,就需 ...

  7. Android Studio 解决格式化快捷键和QQ 锁键盘快捷键冲突

    今天,简单讲讲android studio格式化的快捷键和qq快捷键之间的冲突的处理. 每次,当我打开QQ使用android studio格式化的快捷键Ctrl + Alt +L时,总是出现QQ 锁键 ...

  8. android活动中的变量,在不同的活动中保持变量值Android Studio

    我的应用程序中有选项卡式活动.在每个标签页中,我都有一个(切换)按钮,可以通过单击切换到打开和关闭.当我移动到另一个标签并回到相同的位置时,它就会熄灭.我想保持它的价值,以便在切换到其他活动时不会改变 ...

  9. Android Studio显示“Hardcoded String XXX,should use @string resource”的解决方法2-1

    Android Studio在xml布局文件中,有时会显示"Hardcoded String XXX,should use @string resource"的警告信息.其中Har ...

最新文章

  1. Centos服务器常用安装指南
  2. 平板电脑计算机怎么关按键音,平板电脑输入法怎么设置【图解】
  3. django学习之Model(四)MakingQuery
  4. Python入门第三章--第一节:条件判断语句
  5. OC__part11.2
  6. 美国面试之旅——面试经验分享
  7. docker生成tomcat镜像
  8. react中引入html文件,在react中怎么引用js
  9. 英语口语 week14 Friday
  10. 2012年CISSP考试时间
  11. 导出Oracle数据库字典
  12. Oracle 实用技巧
  13. arcgis for android 调用公网天地图注记重影问题
  14. vue单页面SEO优化
  15. R语言--Apriori关联分析
  16. numpy中takes函数
  17. CSS教程:认真学习haslayout
  18. 解决Windows10系统ping外网不通的问题
  19. 一年级描写下雪的古诗,古诗翻译及重点知识点心田花开汇总
  20. 台式电脑计算机风机,笔记本冷却风扇与台式计算机CPU风扇的质量,类型和区别...

热门文章

  1. Google Net变种以及注意力机制
  2. 【python】注意力机制代码
  3. CityMaker学习教程12 osg模型的创建
  4. 第二关,KPM算法和next函数值
  5. AQS(AbstractQueuedSynchronizer)是什么?
  6. Vulkan 学习笔记
  7. CIC 滤波器——不同长度的单级CIC滤波器的频谱特性
  8. 配置Druid数据源监控
  9. 英剧《反击》中有意思的镜头
  10. make[2]: *** [/home/nnnn/calibration/devel/lib/libcalibrationtoolkit.so] Error 1