Android散打之ScrollView

  1. scrollview 设置paddingTop后,滑动scrollview时,内容不能显示完全,会被padding给遮挡住。
    解决: 设置android:clipToPadding = false;

        <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_paddingTop="280dp"
            android:clipToPadding="false"
        </ScrollView>
  2. 使用DrawerLayout时,若显示的主区域内容包含scrollview时而抽屉的内容区域没有listview或者scrollview,在抽屉打开后,在抽屉上下滑动时,会将上下滑动事件传递给主区域scrollview导致scrollview会上下滑动,这显然不是我们所期望的。解决方法是将抽屉内容包裹在一个scrollview中,这样就不会滑动主区域的scrollview了。

        <android.support.v4.widget.DrawerLayout
            ...
            ...
            >
            <!--主区域内容-->
            <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/app_bar"
                android:layout_width="match_parent"
                android:layout_height="?actionBarSize"
                app:contentInsetStart="12dp"
                app:layout_collapseMode="pin"
                />
            <ScrollView
                android:id="@+id/scrollView"
                android:layout_below="@id/app_bar"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <LinearLayout
                    android:id="@+id/scroll_content"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">
                </LinearLayout>
            </ScrollView>
        </RelativeLayout>
        <!--抽屉的内容-->
        <ScrollView
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="end"
            android:background="@color/colorTranslucence">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="centerInside"
                    android:src="@drawable/ic_login_poster"/>
            </RelativeLayout>
        </ScrollView>
    </android.support.v4.widget.DrawerLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值