概述
效果圖:
可以看到預(yù)設(shè)了非常多的Activity模板,可以方便的添加各種效果,極大的減少部分代碼的編寫。
插件收集
其實上述的效果圖為AS的模板,打開Android Studio的安裝目錄,對于Activity的模板,在plugins\android\lib\templates\activities
如下圖:
每個Activity模板,對應(yīng)一個文件夾,對應(yīng)我們創(chuàng)造Activity時,New Activity,如圖:
除了內(nèi)置的幾個模板,我們可以自己開發(fā),當(dāng)然github上也有部分開源的模板,只需要下載別人提供的模板文件,copy至
{Android Studio installation dir}
\plugins\android\lib\templates\activities
然后重啟Android Studio即可
可參考的插件如下:
- Android-studio-material-template
https://github.com/kanytu/Android-studio-material-template
A template for Android Studio to create applications with material design and Navigation Drawer.包含:MaterialNavigationDrawerActivity。
- android-studio-template
https://github.com/MontazzeStudio/android-studio-template
包含DrawerWithTabsActivity和RecyclerRefreshActivity
- AndroidStudioTemplate
https://github.com/gabrielemariotti/AndroidStudioTemplate 包含SwipeRefreshLayout,還有一些常用的模板。
- 除了Activity模板,還有些其他的模板,下面這個模板就很有意思(PS:不支持搜索略坑):
https://github.com/intrications/material-design-icons-adt-template
用于創(chuàng)建Material Design Icon,可以非常方便的創(chuàng)建Icon,再也不需要自己去找下載各種尺寸了。
當(dāng)然上述這些開源項目理論上只是用于參考,不過講道理我們應(yīng)該自己去學(xué)習(xí)如何編寫這樣的模板,針對我們平時的需求去編寫一些模板,提升開發(fā)效率。
我也給大家找了些模板開發(fā)的相關(guān)鏈接,大家可以參考下。
模板開發(fā)相關(guān)資料
- http://www.lxweimin.com/p/81d03519dd33
- https://www.zhihu.com/question/46979171
- http://www.i-programmer.info/professional-programmer/resources-and-tools/6845-android-adt-template-format-document.html
- https://developer.android.com/studio/projects/templates.html
- http://robusttechhouse.com/tutorial-how-to-create-custom-android-code-templates/
有興趣的可以結(jié)合這些項目和開發(fā)資料嘗試自己開發(fā)一些模板了,本文的目的就是先對Android Studio的模板有個直觀的認(rèn)識。