as升级2.3后新建Activity自动引入约束布局

前言

自从升级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都是手动新建的,我就没去修改了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值