讓你飛快構(gòu)建Android開發(fā)框架----Android Studio Template

上周在QQ群吹水的時候,發(fā)現(xiàn)數(shù)個QQ群被一張神奇的圖刷屏了,大家紛紛表示對該圖有極大的興趣,該圖如下:


1465266410114498.gif

可以看到預設了非常多的Activity模板,可以方便的添加各種效果,極大的減少部分代碼的編寫,
據(jù)說也有人積極聯(lián)系該圖了作者,該作者給出了大致的做法(尋找開源插件copy至as對應插件目錄),在此非常感謝。
本文目的是讓大家對Android Studio Template有個初步的認識~

插件收集
其實上述的效果圖為AS的模板,打開Android Studio的安裝目錄,對于Activity的模板,在

/plugins/android/lib/templates/activities,如下圖:

1465266462800046.png

每個Activity模板,對應一個文件夾,對應我們創(chuàng)造Activity時,New Activity,如圖:


1465266475868037.png

除了內(nèi)置的幾個模板,我們可以自己開發(fā),當然github上也有部分開源的模板,只需要下載別人提供的模板文件,copy至

<code class="hljs tex has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-special" style="box-sizing: border-box; color: rgb(102, 102, 0);">{</span>Android Studio installation dir<span class="hljs-special" style="box-sizing: border-box; color: rgb(102, 102, 0);">}</span> <span class="hljs-command" style="box-sizing: border-box; color: rgb(0, 0, 136);">\plugins</span><span class="hljs-command" style="box-sizing: border-box; color: rgb(0, 0, 136);">\android</span><span class="hljs-command" style="box-sizing: border-box; color: rgb(0, 0, 136);">\lib</span><span class="hljs-command" style="box-sizing: border-box; color: rgb(0, 0, 136);">\templates</span><span class="hljs-command" style="box-sizing: border-box; color: rgb(0, 0, 136);">\activities</span>\</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

然后重啟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模板,還有些其他的模板,下面這個模板就很有意思:

https://github.com/intrications/material-design-icons-adt-template
用于創(chuàng)建Material Design Icon,可以非常方便的創(chuàng)建Icon,再也不需要自己去找下載各種尺寸了。

1465266763636526.png

然后可以選擇創(chuàng)建需要的Icon,如圖:


1465266771467669.png

當然上述這些開源項目理論上只是用于參考,不過講道理我們應該自己去學習如何編寫這樣的模板,針對我們平時的需求去編寫一些模板,提升開發(fā)效率。

我也給大家找了些模板開發(fā)的相關(guān)鏈接,大家可以參考下。
模板開發(fā)相關(guān)資料

http://www.itdecent.cn/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/

轉(zhuǎn)自:http://blog.csdn.net/lmj623565791/article/details/51592043

來源:http://bbs.520it.com/forum.php?mod=viewthread&tid=524&extra=page%3D6

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容