作业问题 ScrollView

作业问题 ScrollView

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

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

代码

<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下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

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