Android常用代码-时间轴布局

  1. 1. 时间轴特征
  2. 2. 效果图
  3. 3. 圆点背景
  4. 4. 布局代码

时间轴特征

  • 某人
  • 某个时间
  • 做了某个事情

效果图

圆点背景

1
2
3
4
5
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#61b4fe" />
</shape>

布局代码

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite">

<LinearLayout
android:layout_width="216px"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="70px"
android:text="13:52"
android:textColor="#666"
android:textSize="36px" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14px"
android:text="01-12"
android:textColor="#999"
android:textSize="31px" />

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">

<View
android:layout_width="1px"
android:layout_height="0dp"
android:layout_marginBottom="5px"
android:layout_weight="1"
android:background="#e5e5e5" />

<View
android:id="@+id/point_state"
android:layout_width="30px"
android:layout_height="30px"
android:layout_centerInParent="true"
android:background="@drawable/point_time_line_first"
app:layout_auto_baseheight="width" />

<View
android:layout_width="1px"
android:layout_height="0dp"
android:layout_marginTop="5px"
android:layout_weight="1"
android:background="#e5e5e5" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40px"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40px"
android:gravity="center_vertical"
android:orientation="horizontal">

<TextView
android:id="@+id/tv_person"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10px"
android:text="王五"
android:textColor="#666"
android:textSize="36px" />

<TextView
android:id="@+id/tv_time_before"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50px"
android:text="10分钟前"
android:textColor="#999"
android:textSize="31px" />
</LinearLayout>

<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40px"
android:layout_marginRight="60px"
android:layout_marginTop="26px"
android:text="进行了首件确认进行了首件确认进行了首件确认进行了首件确认进行了首件确认"
android:textColor="#333"
android:textSize="36px" />
</LinearLayout>
</LinearLayout>