为什么我的ScrollView不能滚动

为什么我的ScrollView不能滚动

我已经检查了几遍了,同时对比了问答区其他同学的问题,实在是不知道为什么不能滑动,求解答

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:orientation="horizontal"
            android:paddingTop="15dp">
 
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal">
 
                <ImageView
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@mipmap/list_my_menu" />
 
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp">
 
                    <TextView
                        android:id="@+id/txt_my_order"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingTop="8dp"
                        android:text="我的订单"
                        android:textSize="28sp" />
 
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@id/txt_my_order"
                        android:layout_marginTop="8dp"
                        android:background="#E3E5E7"></View>
                </RelativeLayout>
 
            </LinearLayout>
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:orientation="horizontal"
            android:paddingTop="15dp">
 
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal">
 
                <ImageView
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@mipmap/list_save" />
 
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp">
 
                    <TextView
                        android:id="@+id/txt_my_save"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingTop="8dp"
                        android:text="我的收藏"
                        android:textSize="28sp" />
 
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@id/txt_my_save"
                        android:layout_marginTop="8dp"
                        android:background="#E3E5E7"></View>
                </RelativeLayout>
 
            </LinearLayout>
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:orientation="horizontal"
            android:paddingTop="15dp">
 
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal">
 
                <ImageView
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@mipmap/list_pwd" />
 
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp">
 
                    <TextView
                        android:id="@+id/txt_my_pwd"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingTop="8dp"
                        android:text="我的口令"
                        android:textSize="28sp" />
 
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@id/txt_my_pwd"
                        android:layout_marginTop="8dp"
                        android:background="#E3E5E7"></View>
                </RelativeLayout>
 
            </LinearLayout>
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:orientation="horizontal"
            android:paddingTop="15dp">
 
            <LinearLayout
                android:id="@+id/part1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal">
 
                <ImageView
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@mipmap/list_my" />
 
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp">
 
                    <TextView
                        android:id="@+id/txt_my"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingTop="8dp"
                        android:text="我的锦囊"
                        android:textSize="28sp" />
 
                </RelativeLayout>
 
            </LinearLayout>
 
        </LinearLayout>
 
        <View
            android:layout_width="match_parent"
            android:layout_height="8dp"
            android:layout_below="@id/txt_my"
            android:layout_marginTop="10dp"
            android:background="#E3E5E7"></View>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:orientation="horizontal"
            android:paddingTop="15dp">
 
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal">
 
                <ImageView
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@mipmap/list_my_menu" />
 
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp">
 
                    <TextView
                        android:id="@+id/txt_my_order1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingTop="8dp"
                        android:text="我的订单"
                        android:textSize="28sp" />
 
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@id/txt_my_order1"
                        android:layout_marginTop="8dp"
                        android:background="#E3E5E7"></View>
                </RelativeLayout>
 
            </LinearLayout>
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:orientation="horizontal"
            android:paddingTop="15dp">
 
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal">
 
                <ImageView
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@mipmap/list_save" />
 
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp">
 
                    <TextView
                        android:id="@+id/txt_my_save1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingTop="8dp"
                        android:text="我的收藏"
                        android:textSize="28sp" />
 
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@id/txt_my_save1"
                        android:layout_marginTop="8dp"
                        android:background="#E3E5E7"></View>
                </RelativeLayout>
 
            </LinearLayout>
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:orientation="horizontal"
            android:paddingTop="15dp">
 
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal">
 
                <ImageView
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@mipmap/list_pwd" />
 
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp">
 
                    <TextView
                        android:id="@+id/txt_my_pwd1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingTop="8dp"
                        android:text="我的口令"
                        android:textSize="28sp" />
 
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@id/txt_my_pwd1"
                        android:layout_marginTop="8dp"
                        android:background="#E3E5E7"></View>
                </RelativeLayout>
 
            </LinearLayout>
        </LinearLayout>
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:orientation="horizontal"
            android:paddingTop="15dp">
 
            <LinearLayout
                android:id="@+id/part11"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal">
 
                <ImageView
                    android:layout_width="48dp"
                    android:layout_height="48dp"
                    android:src="@mipmap/list_my" />
 
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp">
 
                    <TextView
                        android:id="@+id/txt_my1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:paddingTop="8dp"
                        android:text="我的锦囊"
                        android:textSize="28sp" />
 
                </RelativeLayout>
 
            </LinearLayout>
 
        </LinearLayout>
 
        <View
            android:layout_width="match_parent"
            android:layout_height="8dp"
            android:layout_below="@id/txt_my1"
            android:layout_marginTop="10dp"
            android:background="#E3E5E7"></View>
 
    </LinearLayout>
 
</ScrollView>


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
irista23 2019-04-11 10:49:27

老师用的代码多加几条数据就可以滚动了,总体内容高度超过一屏才能有滚动效果。

http://img1.sycdn.imooc.com//climg/5caeab090001bf3404770762.jpg

  • 提问者 慕沐020336 #1
    但是,老师,现在有一个问题(无法传截图,所以我只好口述):我刚刚在真机上再次运行,观察了一下运行结果,我的代码中最下面的我的锦囊,可能确实在屏幕中,但是由于被下面的菜单栏挡住了,如果不能滚动,那岂不是遮住了,有什么办法能够让被遮住的部分滚动到可见区域呢,同时也不想取消下面的菜单栏
    2019-04-11 10:56:26
  • irista23 回复 提问者 慕沐020336 #2
    你可以给ScrollView设置一个固定高度,让其在菜单栏以上滚动
    2019-04-11 11:14:43
  • 提问者 慕沐020336 回复 irista23 #3
    好的,我试试,谢谢老师了
    2019-04-11 11:15:44
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师
插入代码