作业问题 ScrollView

作业问题 ScrollView

我在布局上添加了ScrollView
标签,但是在真机运行的时候滑动不到最低端,发现页会看不见最后一项,也看不见查看更多那一栏

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

代码

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
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.imooc.imoochomework.fragment.FindFragment">
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/find_header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="发现"
            android:textSize="30dp"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
 
            />
        <ImageView
            android:layout_width="40dp"
            android:layout_height="wrap_content"
            android:src="@drawable/find_news"
            android:layout_alignParentRight="true"
            android:layout_marginRight="10dp"
            />
        <View
            android:id="@+id/find_line"
            android:layout_below="@id/find_header"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#D8DDE1"
            />
        <android.support.v7.widget.RecyclerView
            android:id="@+id/rec_find"
            android:layout_marginTop="10dp"
            android:layout_below="@id/find_line"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </android.support.v7.widget.RecyclerView>
        <View
            android:id="@+id/find_line02"
            android:layout_below="@id/rec_find"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:background="#D8DDE1"
            />
        <android.support.v7.widget.RecyclerView
            android:id="@+id/find_double_menu"
            android:layout_below="@id/find_line02"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
        <View
            android:id="@+id/find_line03"
            android:layout_below="@id/find_double_menu"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:background="#D8DDE1"
            />
        <RelativeLayout
            android:layout_below="@id/find_double_menu"
            android:id="@+id/travel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
 
            <TextView
                android:id="@+id/travl_txt"
                android:layout_width="match_parent"
                android:gravity="center"
                android:layout_height="wrap_content"
                android:text="旅行PK"
                android:textSize="20sp"
                android:layout_centerHorizontal="true"
                android:paddingTop="16dp"
                />
            <ImageView
                android:layout_width="55dp"
                android:layout_height="55dp"
                android:src="@drawable/find_reflesh"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                />
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                >
            </LinearLayout>
            <ImageView
                android:id="@+id/pk1"
                android:layout_width="170dp"
                android:layout_height="100dp"
                android:src="@drawable/find_pk1"
                android:layout_below="@id/travl_txt"
                android:layout_marginLeft="5dp"
                />
            <ImageView
                android:id="@+id/pk2"
                android:layout_toRightOf="@id/pk1"
                android:layout_below="@id/travl_txt"
                android:layout_width="180dp"
                android:layout_height="100dp"
                android:src="@drawable/find_pk2"
                android:layout_marginLeft="5dp"
                />
            <ProgressBar
                android:layout_marginLeft="5dp"
                android:id="@+id/progress_left"
                android:layout_width="170dp"
                android:layout_height="wrap_content"
                android:layout_below="@id/pk1"
                 style="@style/Widget.AppCompat.ProgressBar.Horizontal"
                android:progress="64"
                android:progressDrawable="@drawable/progress_style"
                android:clipOrientation="horizontal"
                android:gravity="right"
                android:max="100"
                />
 
            <ProgressBar
                android:layout_marginLeft="5dp"
                android:id="@+id/progress_right"
                android:layout_width="160dp"
                android:layout_height="wrap_content"
                android:layout_below="@id/pk2"
                android:layout_toRightOf="@id/pk1"
                style="@style/Widget.AppCompat.ProgressBar.Horizontal"
                android:progress="70"
                android:progressDrawable="@drawable/progress_vertical_style"
                android:clipOrientation="horizontal"
                android:gravity="right"
                android:max="100"
                />
         <ImageView
             android:layout_width="48dp"
             android:layout_height="48dp"
             android:src="@drawable/find_vs"
             android:layout_below="@id/travl_txt"
             android:layout_centerHorizontal="true"
             android:layout_marginTop="70dp"
             />
<LinearLayout
    android:id="@+id/dianzan"
    android:layout_width="match_parent"
    android:layout_height="65dp"
    android:layout_below="@id/pk1"
    android:layout_marginTop="30dp"
    >
    <include
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        layout="@layout/dian_zan"
        />
</LinearLayout>
 
            <TextView
                android:id="@+id/hotNew"
                android:layout_below="@id/dianzan"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="热门头条"
                android:textSize="20dp"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp"
             android:gravity="center"
                />
            <android.support.v7.widget.RecyclerView
                android:layout_below="@id/hotNew"
                android:id="@+id/hotNews"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                />
            <TextView
                android:id="@+id/more"
                android:layout_below="@id/hotNews"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="查看更多"
                android:textSize="20dp"
                android:textColor="@color/deeppink"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp"
                android:gravity="center"
                />
        </RelativeLayout>
 
    </RelativeLayout>
    </ScrollView>
 
</RelativeLayout>


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

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

1回答
irista23 2018-03-10 22:07:14

建议你把最外层的相对布局改成线性布局,并且让里面的布局子框架也使用线性布局垂直排列。相对布局你需要横向纵向都设置好控件的依赖关系,虽然性能好但处理复杂,且一个位置有问题,其他控件都会受到牵连影响,你要为其中的每一个控件考虑好位置,相比之下,线性布局就简单得多,你只要水平或垂直方向排列就好了,也不会出现重叠遮挡问题。


  • 提问者 小巧的蜗牛 #1
    那么,在实际开发中,怎样判断什么时候使用相对布局,什么时候使用线性布局,什么时候用约束布局?
    2018-03-12 08:30:38
  • irista23 回复 提问者 小巧的蜗牛 #2
    不太复杂,简单的布局用线性,需要嵌套很多层的用相对布局,避免过深的嵌套;google力推约束布局,但需要学习成本灵活掌握,好处是减少了布局带来的消耗,对布局效率要求较高的可以选择,另外布局还是需要根据业务需要以及界面设计来综合考量选择。
    2018-03-12 09:11:55
问题已解决,确定采纳
还有疑问,暂不采纳

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

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

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

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

帮助反馈 APP下载

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

公众号

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

在线咨询

领取优惠

免费试听

领取大纲

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