1. Project structure
The current MVP model is becoming more and more popular. is used by default.
If the project is relatively small:
App--application Activity Fragment presenter, etc. top-level parent class
Config--api, constant table, etc.
model--Data Layer
PRESENTER--MVP's P
service--Service
The UI--MVP V
utils--Tool Class Collection
widget--each reusable View collection
If the project is relatively large, the above way will certainly result in presenter and view hundreds of files. Look at the blind series. The following methods are recommended:
2. Configuring themes
This step is ignored for projects that do not comply with material design.
1. First write the desired color in the Color.xml:
<resources> <color name= "Orange" > #ff5722 </color> <color name= "Deeppurple" > #673AB7 </ color> <color name= "DeepPurple900" > #311B92 </color> <color name= "White" > #fff </color> < Color name= "Gray" > #888888 </color> <color name= "Gray100" > #dddddd </color> <color name= " Gray600 "> #999999 </color> </resources>
Note that color.xml is a color table. It should be a description of the color rather than the definition of the font color, background color, etc. This prevents duplicate definitions of similar colors. And the interface color is not uniform.
2. Defining a Theme in Style.xml:
<style name= "Apptheme.base" parent= "Theme.AppCompat.Light.NoActionBar" > <!-- Customize your theme here. --> <item name= "ColorPrimary" > @color/deeppurple</item> <item name= "Colorprimarydark" >@ Color/deeppurple900</item> <item name= "ColorAccent" > @color /orange</item> </style> < Style name= "Apptheme" parent= "Apptheme.base" >&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;</STYLE>
Under the Res directory, create a values-v21 directory, and then create a style.xml:
<style name= "Apptheme" parent= "Apptheme.base" > <item name= "Android:windowdrawssystembarbackgrounds" > true</item> <item name= "Android:statusbarcolor" >?colorPrimaryDark</item> </style>
Then modify the application theme property in the Androidmanifest.xml file to the Apptheme defined above. The immersive status bar can be implemented.
Then the detailed settings for theme and toolbar refer to my other two blog posts:
Http://www.cnblogs.com/Jude95/p/4369816.html
Http://www.cnblogs.com/Jude95/p/4370176.html
3. Dependent libraries and SDKs
Required library:
gradle-retrolambda--android lambda expression plug-in
fresco--android most cock picture loading library
material-dialogs --material dialog Backward compatible library
material-ripple--ripple backward compatible library
fastjson--fastest JSON parsing
butterknife--view annotation libraries and companion plugins ANDROID-BUTTERKNIFE-ZELEZNY
activeandroid--Database Annotation Library.
rxandroid--rx function responsive programming Chinese document
retrofit, Okhttp,sqlbrite,okio--square Home Boutique More Ah
Below Amway several self-written libraries, if there are any suggestions welcome communication:
Utils--android Collection of small functions
rollviewpager--automatic Viewpager for easy use of the carousel
easyrecyclerview--supports full-featured recyclerview such as pull-up and pull-up refreshes
Swipebackhelper--activity slide off the support library to achieve results
Tried a lot, these are now commonly used.
Bmob--do not ask for the backstage
Bmob--SMS verification 0.01/Article
Cloud--Instant Messaging
Friends League-data statistics, push, feedback, Automatic Updates, third-party sharing and login, community
Seven cows--cloud storage
Rely on this large heap of libraries and SDKs later. It is advisable to initialize them at the right time, rather than the whole heap in application's OnCreate (). This causes the boot time to be too long. It will also be more than a card after startup. Although it does not affect the normal use of functions.
4. Configure Gradle
Some SDK runtimes need to check that the signature is correct. Therefore, the debug mode must also be signed with the official key. It is not advisable to put a signature into version control. So the following procedure is recommended:
Add the following code to the app's Gradle
Properties props = new properties () props.load (New fileinputstream (File (" Signing.properties ")) android { signingconfigs { release{ keyalias props[' Key_alias '] keypassword props[' Key_password '] Storefile file (props[' keystore_file ')) storepassword props[' Keystore_password '] } } buildTypes { release { signingconfig signingconfigs.release } debug { signingConfig signingConfigs.release } }}
Create a new Signing.properties file in the app's Gradle file sibling and fill in the appropriate information for your key
Keystore_file = C:\\users\\mr.jude\\documents\\android\\helloworld.jkskeystore_password = XxxxxxKEY_ALIAS = Xxxxxxkey_password = xxxxxx
Add signing.properties to the Ignore directory.
Other people pull down code after. Build your own new signing.properties fill in the appropriate information can be compiled successfully.
5. Develop the development code
In order to avoid cooperative development writing code style is very different. Or make a number of development patterns. Here is an example. After all, it is designed for efficient development. The best for your project.
This is beneficial for life cycle management. can also be easily modified globally.
naming, example
userdetailactivity
layout named, example
fragment _ACCOUNT
item_person
include_toolbar
VIEW_PROGRESS
ID Name, example
Btn_send
Tv_name
List_persons
Et_password
Then using the Butterknife plugin to generate the variable will automatically change the underscore to the hump name
Variable name: Start with M. Example Madapter when used, press a M all out.
Method naming: Rather than writing a good name, write a good note. = =.
TextView using official Standard fonts
650) this.width=650; "src=" Https://static.oschina.net/uploads/img/201611/14152726_iIPK.png "style=" margin:0px; padding:0px;border:0px; "alt=" 14152726_iipk.png "/>
Textview.png
style= "@style/textappearance.appcompat.display4" style= "@style/textappearance.appcompat.display3" style= "@style/textappearance.appcompat.display2" style= "@style/textappearance.appcompat.display1" style= "@style/textappearance.appcompat.headline" style= "@style/textappearance.appcompat.title" style = "@style/textappearance.appcompat.subhead" style= "@style/textappearance.appcompat.body2" style= "@ Style/textappearance.appcompat.body1 " style=" @style/textappearance.appcompat.caption " style=" @style/ TextAppearance.AppCompat.Button "
Button using material design standard style
650) this.width=650; "src=" Https://static.oschina.net/uploads/img/201611/14152726_p21q.png "style=" margin:0px; padding:0px;border:0px; "alt=" 14152726_p21q.png "/>
Button.png
style= "@style/widget.appcompat.button" style= "@style/widget.appcompat.button.borderless" style= "@style/ Widget.AppCompat.Button.Borderless.Colored "style=" @style/widget.appcompat.button.small "
Set up the network request to the wording. How and where the files are stored. Write the usage of the class library framework used by the project.
Wen/jude95 (author of Jane's book)
Original link: http://www.jianshu.com/p/d9e4ddd1c530
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".
This article is from the "11992900" blog, please be sure to keep this source http://12002900.blog.51cto.com/11992900/1872679
A good Android app starts with a project