前言
自从升级2.3后,每次新建Activity都变成了引入约束布局,各种不爽,这里提供修改的办法。
修改默认布局
修改新建时的布局文件。
找到安装目录下\plugins\Android\lib\templates\activities\common\root\res\layout\simple.xml.ftl文件,修改文件,改成自己喜欢的,比如RelativeLayout 布局,LinearLayout布局。例如LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
<#if hasAppBar && appBarLayoutName??>
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/${appBarLayoutName}"
</#if>
tools:context="${relativePackage}.${activityClass}">
<#if isNewProject!false>
<TextView
<#if includeCppSupport!false>
android:id="@+id/sample_text"
</#if>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</#if>
</LinearLayout>
重启后新建发现app/build.gradle会自动添加constraint-layout的包。接下来就是修改build.gradle,一开始使用笨办法,一个个build.gradle去翻,结果都没看到,后来干脆直接用命令去查找:
最后发现在\plugins\android\lib\templates\activities\common\recipe_simple.xml.ftl中,把下面这一行删掉就可以了
<dependency mavenUrl="com.android.support.constraint:constraint-layout:+" />
至于recipe_fragment.xml.ftl也同样方法,不过得我的Fragment都是手动新建的,我就没去修改了