Can I change the default layout in Android Studio?

可紊 提交于 2020-01-14 02:06:05

问题


When I create a new project with a Blank Activity in Android Studio, it uses a RelativeLayout by default. I'd like to change that Blank Activity default to LinearLayout, rather than editing each activity - is that possible?


回答1:


I have already answered this question here: How to change a default template files in Android Studio.

Basically you need to look at the recipe_fragment.xml.ftl file, so you, know which files are used for the template.

The default template files are located in:

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

So according to the recipe for the BlankActivity template, it says that it uses ../common/recipe_simple.xml.ftl (if you dont't want to use a fragment layout) according to that recipe, it says that is uses this file to build the BlankActivity:

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

by simply replacing RelativeLayout with LinearLayout in your favourite text editor (move the file to the Desktop and edit it over there), you get what you want, but instead of that, I recommend you to make your own template, where you can define literally anything.



来源:https://stackoverflow.com/questions/34404428/can-i-change-the-default-layout-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!