为什么我的ScrollView不能滚动

为什么我的ScrollView不能滚动

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

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

在线咨询

领取优惠

免费试听

领取大纲

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