Fork me on GitHub

一个完整app开发流程

1.给出功能文档

2.APP架构选择

可选MVP,MVVM

3.APP目录结构设置

本app基于mvp架构。除了mvp架构的文件。
还包含下面的文件夹:
ui (下面根据Activity划分)
widget (自定义dialog等)
base (BaseActivity,BaseFragment)

4.划分Activity与Fragment

有侧滑栏,tab的一般用fragment

5.分辨率适配

设置sw-360dp,sw-480dp等不同的dimension目录,根据百分比计算dp值。

6.三方库使用

bindview使用butterknife,不同组件通信使用EventBus,定时使用RxJava,崩溃收集bugly

7.自定义view

按钮样式:
使用selector

1
2
3
4
5
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@mipmap/ic_button_b_pressed"/>
<item android:drawable="@mipmap/ic_button_b_normal"/>
</selector>

按钮背景色,包括颜色和圆角

1
2
3
4
5
6
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ff9ca4b1" />
<corners android:topLeftRadius="@dimen/dp_12_dp" android:topRightRadius="@dimen/dp_12_dp" android:bottomLeftRadius="@dimen/dp_12_dp" android:bottomRightRadius="@dimen/dp_12_dp" />
</shape>

8.布局方式

使用ConstraintLayout,直接使用标注的值来做,最简单,不要用百分比。使用layout_constraint,layout_margin完成所有布局。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:paddingBottom="@dimen/dp_24_dp"
android:layout_height="wrap_content"
android:background="@drawable/base_bg_dialog1">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="@dimen/dp_24_dp"
android:layout_marginEnd="8dp"
android:text="@string/tip"

android:textSize="@dimen/sp_20_sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />


<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="@dimen/dp_24_dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="@dimen/dp_24_dp"

android:textSize="@dimen/sp_19_sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />

<TextView
android:id="@+id/tv_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_24_dp"
android:layout_marginRight="@dimen/dp_60_dp"
android:padding="@dimen/dp_10_dp"
android:text="@string/cancel"

android:background="@drawable/bg_text_button2"
android:textSize="@dimen/sp_19_sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tv_sure"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_content" />


<TextView
android:id="@+id/tv_sure"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_24_dp"
android:padding="@dimen/dp_10_dp"
android:text="@string/sure"

android:textSize="@dimen/sp_19_sp"
android:background="@drawable/bg_text_button2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/tv_cancel"
app:layout_constraintTop_toBottomOf="@+id/tv_content" />

</androidx.constraintlayout.widget.ConstraintLayout>

在AndroidStudio直接肉眼布局,Android可以选择不同的分辨率机器,水平或者垂直进行预览

9.编译系统配置

配置sdk版本
配置abi

10.图片配置

使用蓝湖进行图片的协助。提供m,h,x,xx等不同分辨率的图片

-------------本文结束感谢阅读-------------