0

Android Studio provides a number of templates for new items - activities, fragments, services etc.

enter image description here

Is there a way to create a custom one? I'm using databinding extensively and I'd like to create a template, which would automatically add a viewmodel, create layout file with layout root item, prepare code to bind viewmodel etc.

Spook
  • 25,318
  • 18
  • 90
  • 167
  • Yes you can create it. using gradle-projects/NewAndroidModule I think this [here](http://stackoverflow.com/questions/24546484/how-to-create-custom-project-template-in-android-studio) may be useful – khakishoiab Sep 27 '16 at 10:45

1 Answers1

3

There are several tutorials on this. E.g., here and here. The upshot is that the templates are written in freemarker template files. These have to be placed inside a sub-directory under the actual Android Studio application (e.g., on a mac it's in /Applications/Android Studio.app/Contents/plugins/android/lib/templates/...).

Personally, I've been looking for a way to have these stored in a project-specific location (e.g., in the project repository), but have so far not found a way to do that. I think you can only make these available by placing them in that sub-directory under the application's folder.

stuckj
  • 977
  • 1
  • 13
  • 24