Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change the default layout in Android Studio?

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?

like image 544
joelt Avatar asked Dec 15 '25 19:12

joelt


1 Answers

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.

like image 164
Matcoil Avatar answered Dec 17 '25 14:12

Matcoil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!