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
- The VIEW--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:
- App
- Config
- Model
- module--assigns the interface layer to the function module to assign the package.
- Launch
- Main
- Account
- News
- Music
- ......
- Utils
- Widgets
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><ColorName="Orange" > #ff5722</Color><ColorName="Deeppurple" > #673AB7</Color><ColorName="DeepPurple900" > #311B92</Color><Colorname= "white" > #fff </color> <color name= "Gray" > #888888 </color> <color name= "Gray100" > #dddddd </< Span class= "Hljs-title" >color> <color name= "Gray600" > #999999 </< Span class= "Hljs-title" >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. Define the theme in Style.xml:
<StyleName="Apptheme.base"Parent="Theme.AppCompat.Light.NoActionBar" ><!--CustomizeYourtheme 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" > </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 libraries:
Gradle-retrolambda--android lambda expression plug-in
Fresco--android most cock pictures load library
Material-dialogs--material Dialog Backward compatible library
Material-ripple--ripple Backward Compatible Library
fastjson--the fastest JSON parsing
Butterknife--view Annotation Library and companion plugin Android-butterknife-zelezny
activeandroid--Database Annotation Library.
Rxandroid--rx Functional Responsive Programming Chinese documents
Retrofit,okhttp,sqlbrite,okio--square is a lot of boutique.
compile ‘com.android.support:design:23.0.1‘
--Google Material Design Control Library
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.
Cloud--Instant Messaging
Friends League-data statistics, push, feedback, Automatic Updates, third-party sharing and login, community
Seven cows--cloud storage
mob--SMS Verification
bmob--do backstage do not beg
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.
All activity Inheritance Baseactivity
All fragment Inherit Basefragment
All presenter Inherit Basepresenter
This facilitates life cycle management. can also be easily modified globally.
Name, example
AccountFragment
UserDetailActivity
Layout naming, example
activity_collection
fragment_account
item_person
include_toolbar
view_progress
But for the development of large projects. Nearly hundreds of activity-beginning layout lists are still blind. So that would add the module name to the front.
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. 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
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
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.
OK, let's start the formal development! If there is any suggestion welcome the communication. This article will also be modified immediately.
A good Android app starts with a project