新建一个优秀的Andoroid-mvp项目
1.项目结构
如果项目比较小的话:
app——Application Activity Fragment Presenter等的顶级父类
config——API,常量表等
model——数据层
entities——数据模型
presenter——MVP的P
service——服务
ui——MVP的V
utils——工具类集合
widget——各个可复用View集合
如果项目比较大,上面的方式一定会造成presenter和view里近百个文件。看瞎眼系列。推荐下列方式:
app
config
model
entities
module——将界面层以功能模块分配包。
launchmain
account
news
music
……
utils
widget
2.配置主题
对于不遵守Material Design的项目无视这一步。
1.先在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>
注意color.xml是配色表。应该是描述颜色而不是对字体颜色,背景颜色等的定义。这样能防止相近的颜色重复定义。而导致界面颜色不统一。
2.在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"></style>
在res目录下,创建一个values-v21目录,再创建一个style.xml:
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">?colorPrimaryDark</item></style>
然后在AndroidManifest.xml文件中修改application的theme属性为上面定义的AppTheme.即可实现沉浸式状态栏。
然后关于Theme与Toolbar的详细设置参考博客:
http://www.cnblogs.com/Jude95/p/4369816.html
http://www.cnblogs.com/Jude95/p/4370176.html
3.依赖库与SDK
必选的库:
gradle-retrolambda——Android的lambda表达式插件
fresco——Android最屌图片加载库
material-dialogs ——Material Dialog向下兼容库
material-ripple——Ripple向下兼容库
fastjson——最快JSON解析
butterknife——View注解库和配套插件android-butterknife-zelezny
ActiveAndroid——数据库注解库。
RxAndroid——Rx函数响应式编程中文文档
retrofit,okhttp,sqlbrite,okio——Square家的精品多啊
compile ‘com.android.support:design:23.0.1’——谷歌Material Design控件库
几个常用库:
Utils——Android各种小功能集合
RollViewPager——自动轮播使用方便的ViewPager
EasyRecyclerView——支持下拉上拉刷新等功能全面的RecyclerView
SwipeBackHelper——Activity滑动关闭支持库,能达到微信效果
尝试了很多,这几个是现在常用的。
融云——即时通讯
友盟——数据统计,推送,意见反馈,自动更新,第三方分享及登录,社区
七牛——云存储
Mob——短信验证
Bmob——做后台不求人
依赖这一大堆库和SDK以后。建议在合适的时机初始化他们,而不是全堆在Application的onCreate()里面。这样会导致启动时间过长。启动后也会较卡。虽然是不会影响功能正常使用。
4.配置Gradle
某些SDK运行时需要检查签名是否正确。所以在debug模式时也必须用正式KEY签名。而把签名放进版本控制不是明智的做法。所以推荐下面的做法:
在app的gradle加入下面代码
1 | `Properties props = new Properties() |
KEYSTORE_FILE = C:\\Users\\Mr.Jude\\Documents\\Android\\HelloWorld.jks KEYSTORE_PASSWORD = xxxxxx KEY_ALIAS = xxxxxx KEY_PASSWORD = xxxxxx
1 | 其他人pull下来代码后。自己新建signing.properties填入相应信息后即可编译成功。 |
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"
1 |
style="@style/Widget.AppCompat.Button" style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless.Colored" style="@style/Widget.AppCompat.Button.Small"
原文链接:[http://www.jianshu.com/p/d9e4ddd1c530](http://www.jianshu.com/p/d9e4ddd1c530)