Android Studio如何把约束布局(ConstraintLayout)改为相对布局(RelativeLayout)

来源:互联网 发布:淘宝如何买到正品 编辑:程序博客网 时间:2024/06/14 14:21

前言:Android Studio升级到2.3之后新建Activity布局变成了约束(ConstraintLayout)布局,新手可能还不大会用,所以相对布局(RelativeLayout)的控件拖拽定位比较合适。
1.在Android Studio安装目录\plugins\android\lib\templates\activities\common\root\res\layout下,找到simple.xml.ftl文件,并打开


C:\Program Files\Android\Android Studio\plugins\android\lib\templates\activities\common\root\res\layout
(默认安装的同学直接复制上面地址打开就可以啦)

这里写图片描述
2.把下面代码复制替换掉原来的布局

<RelativeLayout 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"    tools:context="${relativePackage}.${activityClass}">    <TextView        android:text="@string/hello_world"        android:layout_width="wrap_content"        android:layout_height="wrap_content" /></RelativeLayout>

3.重启Android Studio,OK!
这里写图片描述
end、、、、、、