如何在Android Studio中更改默认模板布局文件 [英] How to change default template layout files in Android Studio

查看:597
本文介绍了如何在Android Studio中更改默认模板布局文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,每次创建具有某些活动的新项目时,Android Studio都会使用RelativeLayout作为根元素和一个TextView生成一个默认的activity_main.xml文件.但是我更喜欢使用无任何嵌套视图的LinearLayout.如何更改Android Studio生成默认activity_main.xml的方式?

As you know every time you create new project with some activity, Android Studio generates a default activity_main.xml file with RelativeLayout as the root element and one TextView. But I prefer to use LinearLayout without any nested views. How can I change the way Android Studio generates the default activity_main.xml?

推荐答案

您可以通过编辑位于以下位置的默认模板文件来实现:

You can do that by editing default template files, which are located in:

...\Android\Android Studio\plugins\android\lib\templates\activities

例如,EmptyActivity模板的默认布局文件(请注意:这是特定的,其他的都有自己的res文件夹)位于:

so for example, default layout file for template of EmptyActivity (note: this one is specific, the other ones have their own res folders) is located in:

...\Android\Android Studio\plugins\android\lib\templates\activities\common\root\res\layout\simple.xml.ftl

只需在您喜欢的文本编辑器中用LinearLayout替换RelativeLayout,即可获得所需的内容,但我建议您制作自己的模板,根据您的需求在其中定义任何内容.

by simply replacing RelativeLayout with LinearLayout in your favourite text editor, you get what you want, but instead of that, I recommend you to make your own template, where you can define literally anything, according to your desires.

有关BlankActivity以及如何编辑其他模板的指南,请参见以下链接: 如何更改BlankActivity模板默认文件以及如何对其他文件进行更改的指南.

For the BlankActivity and a guide how to edit the other templates see this link: How to change a BlankActivity template default files and a guide how to do it for any others.

这篇关于如何在Android Studio中更改默认模板布局文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆