Reputation: 25927
Android Studio provides a number of templates for new items - activities, fragments, services etc.
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.
Upvotes: 0
Views: 1702
Reputation: 996
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.
Upvotes: 3