April 14, 2026
Welcome

安卓复习

布局方式1

方式1.png

xml
1<?xml version="1.0" encoding="utf-8"?>
2<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3    android:layout_width="match_parent"
4    android:layout_height="match_parent">
5
6    <LinearLayout
7        android:layout_width="match_parent"
8        android:layout_height="match_parent"
9        android:orientation="vertical">
10        <FrameLayout
11            android:layout_width="match_parent"
12            android:layout_height="wrap_content">
13            <ImageView
14                android:layout_width="match_parent"
15                android:layout_height="wrap_content"
16                android:src="@drawable/sousuo"/>
17            <EditText
18                android:layout_width="230dp"
19                android:layout_height="wrap_content"
20                android:hint="在这里输入要搜索的内容"
21                android:layout_marginLeft="55dp"
22                android:layout_marginTop="17dp"/>
23        </FrameLayout>
24
25        <TableLayout
26            android:layout_width="match_parent"
27            android:layout_height="wrap_content"
28            android:stretchColumns="0,1,2,3">
29            <TableRow>
30                <ImageView
31                    android:src="@drawable/tianmao"
32                    android:adjustViewBounds="true"
33                    android:maxHeight="50dp"/>
34                <ImageView
35                    android:src="@drawable/butie"
36                    android:adjustViewBounds="true"
37                    android:maxHeight="50dp"/>
38                <ImageView
39                    android:src="@drawable/chongzhi"
40                    android:adjustViewBounds="true"
41                    android:maxHeight="50dp"/>
42                <ImageView
43                    android:src="@drawable/eleme"
44                    android:adjustViewBounds="true"
45                    android:maxHeight="50dp"/>
46            </TableRow>
47            <TableRow>
48                <TextView
49                    android:text="天猫"
50                    android:textSize="18sp"
51                    android:textColor="#666666"
52                    android:gravity="center"/>
53                <TextView
54                    android:text="补贴"
55                    android:textSize="18sp"
56                    android:textColor="#666666"
57                    android:gravity="center"/>
58                <TextView
59                    android:text="充值"
60                    android:textSize="18sp"
61                    android:textColor="#666666"
62                    android:gravity="center"/>
63                <TextView
64                    android:text="饿了么"
65                    android:textSize="18sp"
66                    android:textColor="#666666"
67                    android:gravity="center"/>
68            </TableRow>
69        </TableLayout>
70
71        <LinearLayout
72            android:layout_width="match_parent"
73            android:layout_height="wrap_content"
74            android:orientation="horizontal">
75            <ImageView
76                android:layout_width="wrap_content"
77                android:layout_height="wrap_content"
78                android:src="@drawable/zhibo"
79                android:paddingLeft="20dp"
80                android:paddingRight="20dp"
81                android:paddingTop="5dp"
82                android:paddingBottom="5dp"
83                android:adjustViewBounds="true"
84                android:layout_weight="1"/>
85            <ImageView
86                android:layout_width="wrap_content"
87                android:layout_height="wrap_content"
88                android:src="@drawable/xianshi"
89                android:paddingLeft="20dp"
90                android:paddingRight="20dp"
91                android:paddingTop="5dp"
92                android:paddingBottom="5dp"
93                android:adjustViewBounds="true"
94                android:layout_weight="1"/>
95        </LinearLayout>
96
97        <LinearLayout
98            android:layout_width="match_parent"
99            android:layout_height="wrap_content"
100            android:orientation="horizontal">
101            <ImageView
102                android:layout_width="wrap_content"
103                android:layout_height="wrap_content"
104                android:src="@drawable/baiyi"
105                android:paddingLeft="20dp"
106                android:paddingRight="20dp"
107                android:paddingTop="5dp"
108                android:paddingBottom="5dp"
109                android:adjustViewBounds="true"
110                android:layout_weight="1"/>
111            <LinearLayout
112                android:layout_width="wrap_content"
113                android:layout_height="wrap_content"
114                android:layout_weight="1"
115                android:orientation="vertical"
116                android:paddingLeft="20dp"
117                android:paddingRight="20dp"
118                android:paddingTop="5dp"
119                android:paddingBottom="5dp">
120                <ImageView
121                    android:layout_width="wrap_content"
122                    android:layout_height="wrap_content"
123                    android:src="@drawable/huoba"
124                    android:adjustViewBounds="true"
125                    android:maxWidth="160dp"/>
126                <TextView
127                    android:layout_width="wrap_content"
128                    android:layout_height="wrap_content"
129                    android:text="小夜灯卧室睡眠灯声控"
130                    android:textSize="16sp"
131                    android:textColor="#353535"
132                    android:layout_marginTop="15dp"/>
133                <TextView
134                    android:layout_width="wrap_content"
135                    android:layout_height="wrap_content"
136                    android:text="¥25.9券后价"
137                    android:textSize="16sp"
138                    android:textColor="#FD4C00"
139                    android:layout_marginTop="10dp"/>
140            </LinearLayout>
141        </LinearLayout>
142    </LinearLayout>
143
144    <LinearLayout
145        android:layout_width="match_parent"
146        android:layout_height="wrap_content"
147        android:orientation="horizontal"
148        android:layout_gravity="bottom"
149        android:background="#EEFFFFFF">
150        <ImageView
151            android:layout_width="wrap_content"
152            android:layout_height="wrap_content"
153            android:src="@drawable/b_taobao"
154            android:padding="10dp"
155            android:adjustViewBounds="true"
156            android:maxWidth="60dp"/>
157        <TableLayout
158            android:layout_width="match_parent"
159            android:layout_height="wrap_content"
160            android:stretchColumns="0,1,2,3"
161            android:paddingTop="5dp"
162            android:layout_gravity="center">
163            <TableRow>
164                <ImageView
165                    android:src="@drawable/b_guangguang"
166                    android:adjustViewBounds="true"
167                    android:maxHeight="32dp"/>
168                <ImageView
169                    android:src="@drawable/b_xiaoxi"
170                    android:adjustViewBounds="true"
171                    android:maxHeight="32dp"/>
172                <ImageView
173                    android:src="@drawable/b_gouwuche"
174                    android:adjustViewBounds="true"
175                    android:maxHeight="32dp"/>
176                <ImageView
177                    android:src="@drawable/b_wode"
178                    android:adjustViewBounds="true"
179                    android:maxHeight="32dp"/>
180            </TableRow>
181            <TableRow>
182                <TextView
183                    android:text="逛逛"
184                    android:textColor="#242424"
185                    android:gravity="center"/>
186                <TextView
187                    android:text="消息"
188                    android:textColor="#242424"
189                    android:gravity="center"/>
190                <TextView
191                    android:text="购物车"
192                    android:textColor="#242424"
193                    android:gravity="center"/>
194                <TextView
195                    android:text="我的"
196                    android:textColor="#242424"
197                    android:gravity="center"/>
198            </TableRow>
199        </TableLayout>
200    </LinearLayout>
201
202</FrameLayout>

布局方式2

方式2.png

xml
1<?xml version="1.0" encoding="utf-8"?>
2<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3    android:layout_width="match_parent"
4    android:layout_height="match_parent"
5    android:padding="10dp">
6
7    <ImageView
8        android:id="@+id/sousuo"
9        android:layout_width="match_parent"
10        android:layout_height="wrap_content"
11        android:adjustViewBounds="true"
12        android:src="@drawable/sousuo" />
13
14    <EditText
15        android:id="@+id/et_sousuo"
16        android:layout_width="230dp"
17        android:layout_height="wrap_content"
18        android:layout_alignTop="@id/sousuo"
19        android:layout_marginStart="50dp"
20        android:hint="输入内容" />
21
22    <LinearLayout
23        android:id="@+id/ll1"
24        android:layout_width="match_parent"
25        android:layout_height="wrap_content"
26        android:layout_below="@id/sousuo"
27        android:layout_marginTop="5dp"
28        android:orientation="horizontal">
29
30        <LinearLayout
31            android:layout_width="0dp"
32            android:layout_height="wrap_content"
33            android:layout_weight="1"
34            android:orientation="vertical">
35
36            <ImageView
37                android:layout_width="wrap_content"
38                android:layout_height="wrap_content"
39                android:layout_gravity="center"
40                android:adjustViewBounds="true"
41                android:maxHeight="40dp"
42                android:src="@drawable/tianmao" />
43
44            <TextView
45                android:layout_width="wrap_content"
46                android:layout_height="wrap_content"
47                android:layout_gravity="center"
48                android:text="天猫" />
49        </LinearLayout>
50
51        <LinearLayout
52            android:layout_width="0dp"
53            android:layout_height="wrap_content"
54            android:layout_weight="1"
55            android:orientation="vertical">
56
57            <ImageView
58                android:layout_width="wrap_content"
59                android:layout_height="wrap_content"
60                android:layout_gravity="center"
61                android:adjustViewBounds="true"
62                android:maxHeight="40dp"
63                android:src="@drawable/tianmao" />
64
65            <TextView
66                android:layout_width="wrap_content"
67                android:layout_height="wrap_content"
68                android:layout_gravity="center"
69                android:text="天猫" />
70        </LinearLayout>
71
72        <LinearLayout
73            android:layout_width="0dp"
74            android:layout_height="wrap_content"
75            android:layout_weight="1"
76            android:orientation="vertical">
77
78            <ImageView
79                android:layout_width="wrap_content"
80                android:layout_height="wrap_content"
81                android:layout_gravity="center"
82                android:adjustViewBounds="true"
83                android:maxHeight="40dp"
84                android:src="@drawable/tianmao" />
85
86            <TextView
87                android:layout_width="wrap_content"
88                android:layout_height="wrap_content"
89                android:layout_gravity="center"
90                android:text="天猫" />
91        </LinearLayout>
92
93        <LinearLayout
94            android:layout_width="0dp"
95            android:layout_height="wrap_content"
96            android:layout_weight="1"
97            android:orientation="vertical">
98
99            <ImageView
100                android:layout_width="wrap_content"
101                android:layout_height="wrap_content"
102                android:layout_gravity="center"
103                android:adjustViewBounds="true"
104                android:maxHeight="40dp"
105                android:src="@drawable/tianmao" />
106
107            <TextView
108                android:layout_width="wrap_content"
109                android:layout_height="wrap_content"
110                android:layout_gravity="center"
111                android:text="天猫" />
112        </LinearLayout>
113    </LinearLayout>
114
115    <LinearLayout
116        android:id="@+id/ll2"
117        android:layout_width="match_parent"
118        android:layout_height="wrap_content"
119        android:layout_below="@id/ll1"
120        android:layout_marginTop="5dp"
121        android:orientation="horizontal">
122
123        <ImageView
124            android:layout_width="0dp"
125            android:layout_height="wrap_content"
126            android:layout_weight="1"
127            android:adjustViewBounds="true"
128            android:maxHeight="250dp"
129            android:paddingLeft="10dp"
130            android:paddingTop="5dp"
131            android:paddingRight="10dp"
132            android:paddingBottom="5dp"
133            android:src="@drawable/zhibo" />
134
135        <ImageView
136            android:layout_width="0dp"
137            android:layout_height="wrap_content"
138            android:layout_weight="1"
139            android:adjustViewBounds="true"
140            android:maxHeight="250dp"
141            android:paddingLeft="10dp"
142            android:paddingTop="5dp"
143            android:paddingRight="10dp"
144            android:paddingBottom="5dp"
145            android:src="@drawable/zhibo" />
146    </LinearLayout>
147
148    <LinearLayout
149        android:id="@+id/ll3"
150        android:layout_width="match_parent"
151        android:layout_height="wrap_content"
152        android:layout_below="@id/ll2"
153        android:layout_marginTop="10dp"
154        android:orientation="horizontal">
155
156        <ImageView
157            android:layout_width="0dp"
158            android:layout_height="wrap_content"
159            android:layout_weight="1"
160            android:adjustViewBounds="true"
161            android:maxHeight="250dp"
162            android:paddingLeft="10dp"
163            android:paddingTop="5dp"
164            android:paddingRight="10dp"
165            android:paddingBottom="5dp"
166            android:src="@drawable/zhibo" />
167
168        <LinearLayout
169            android:layout_width="0dp"
170            android:layout_height="250dp"
171            android:layout_weight="1"
172            android:orientation="vertical"
173            android:paddingLeft="10dp"
174            android:paddingTop="5dp"
175            android:paddingRight="10dp"
176            android:paddingBottom="5dp">
177
178            <ImageView
179                android:layout_width="wrap_content"
180                android:layout_height="wrap_content"
181                android:layout_gravity="center_horizontal"
182                android:adjustViewBounds="true"
183                android:maxWidth="160dp"
184                android:src="@drawable/huoba" />
185
186            <TextView
187                android:layout_width="wrap_content"
188                android:layout_height="wrap_content"
189                android:layout_marginLeft="8dp"
190                android:text="小夜灯" />
191
192            <TextView
193                android:layout_width="wrap_content"
194                android:layout_height="wrap_content"
195                android:layout_marginLeft="8dp"
196                android:text="¥20" />
197        </LinearLayout>
198    </LinearLayout>
199
200    <LinearLayout
201        android:layout_width="match_parent"
202        android:layout_height="wrap_content"
203        android:layout_alignParentBottom="true"
204        android:background="#DFFF"
205        android:gravity="center"
206        android:orientation="horizontal"
207        android:paddingTop="5dp">
208
209        <ImageView
210            android:layout_width="0dp"
211            android:layout_height="wrap_content"
212            android:layout_weight="1"
213            android:adjustViewBounds="true"
214            android:maxWidth="50dp"
215            android:maxHeight="50dp"
216            android:src="@drawable/b_taobao" />
217
218        <LinearLayout
219            android:layout_width="0dp"
220            android:layout_height="wrap_content"
221            android:layout_weight="1"
222            android:gravity="center"
223            android:orientation="vertical">
224
225            <ImageView
226                android:layout_width="wrap_content"
227                android:layout_height="wrap_content"
228                android:adjustViewBounds="true"
229                android:maxWidth="40dp"
230                android:src="@drawable/b_guangguang" />
231
232            <TextView
233                android:layout_width="wrap_content"
234                android:layout_height="wrap_content"
235                android:text="逛逛" />
236        </LinearLayout>
237
238        <LinearLayout
239            android:layout_width="0dp"
240            android:layout_height="wrap_content"
241            android:layout_weight="1"
242            android:gravity="center"
243            android:orientation="vertical">
244
245            <ImageView
246                android:layout_width="wrap_content"
247                android:layout_height="wrap_content"
248                android:adjustViewBounds="true"
249                android:maxWidth="40dp"
250                android:src="@drawable/b_guangguang" />
251
252            <TextView
253                android:layout_width="wrap_content"
254                android:layout_height="wrap_content"
255                android:text="逛逛" />
256        </LinearLayout>
257
258        <LinearLayout
259            android:layout_width="0dp"
260            android:layout_height="wrap_content"
261            android:layout_weight="1"
262            android:gravity="center"
263            android:orientation="vertical">
264
265            <ImageView
266                android:layout_width="wrap_content"
267                android:layout_height="wrap_content"
268                android:adjustViewBounds="true"
269                android:maxWidth="40dp"
270                android:src="@drawable/b_guangguang" />
271
272            <TextView
273                android:layout_width="wrap_content"
274                android:layout_height="wrap_content"
275                android:text="逛逛" />
276        </LinearLayout>
277
278        <LinearLayout
279            android:layout_width="0dp"
280            android:layout_height="wrap_content"
281            android:layout_weight="1"
282            android:gravity="center"
283            android:orientation="vertical">
284
285            <ImageView
286                android:layout_width="wrap_content"
287                android:layout_height="wrap_content"
288                android:adjustViewBounds="true"
289                android:maxWidth="40dp"
290                android:src="@drawable/b_guangguang" />
291
292            <TextView
293                android:layout_width="wrap_content"
294                android:layout_height="wrap_content"
295                android:text="逛逛" />
296        </LinearLayout>
297    </LinearLayout>
298
299</RelativeLayout>
300

Enjoyed this article?

Share it with your friends and colleagues!

Welcome
Last updated: April 14, 2026
相关文章
正在检查服务状态...
安卓复习 - kuno