解决ScrollView底部有布局,不能滑动的问题

原文:https://blog.csdn.net/glmxzaj/article/details/50774616
今天在做项目时用到ScrollView,我发现如果在ScrollView控件之后没有别的布局时它能正常滑动.但是如果我在ScrollView之后又加了一个布局,比如我在屏幕最底部加了一个RelativeLaout 时ScrollView就不能滑动了.

下面我说下我的解决办法: 大家先看下我原来的布局:

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#EEEEEE" >

    <include
        android:id="@+id/top_commit_order"
        layout="@layout/base_top_layout" />

    <ScrollView
        android:id="@+id/sv_commit_order"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/top_commit_order"
        android:layout_marginBottom="15dp"
        android:scrollbars="none" >
   <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            
            >
         
         </RelativeLayout>
    </ScrollView>
    
 <RelativeLayout
        android:id="@+id/rl_commit_order"
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_height="49dp"
        android:background="@color/white" >

      
    </RelativeLayout> 
    
</RelativeLayout>

这个样子是不行的,我通过在网上搜索发现了以下结局办法,以下是更改后的布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#EEEEEE" >

    <include
        android:id="@+id/top_commit_order"
        layout="@layout/base_top_layout" />

 <RelativeLayout
        android:id="@+id/rl_commit_order"
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_height="49dp"
        android:background="@color/white" >

      
    </RelativeLayout> 
    
    <ScrollView
        android:id="@+id/sv_commit_order"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/top_commit_order"
        android:layout_above="@id/rl_commit_or"
        android:layout_marginBottom="15dp"
        android:scrollbars="none" >
   <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            
            >
         
         </RelativeLayout>
    </ScrollView>
</RelativeLayout>

大家发现没,我是把底部的布局移动到ScrollView上面了,并在ScrollView中加入了一个属性 android:layout_above="@id/rl_commit_or",rl_commit_or正是底部的布局如此便能够滑动了

解决Android ScrollView嵌套RecyclerView出现数据展示不全及滑动卡顿问题
https://blog.csdn.net/a_kevin/article/details/86629758

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值