首页 > 其他 > 详细

SwipeRefreshLayout的高度测量

时间:2016-05-28 01:19:05      阅读:488      评论:0      收藏:0      [点我收藏+]

感谢此作者的分享 http://www.cnblogs.com/linjzong/p/5221604.html

若SwipeRefreshLayout的子布局为一个线性布局LinearLayout,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    //红色背景

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:background="#ff00ff">

        //黄色背景

        <android.support.v4.widget.SwipeRefreshLayout
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:background="#ffff00">

            //黑色背景

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:background="#000000" />
        </android.support.v4.widget.SwipeRefreshLayout>
    </ScrollView>
</LinearLayout>
>

技术分享

显示结果确实这个样子的:我们设置100dp显然没起到作用

原来是子View被强制设置成了SwipeRefreshLayout的高度

 自此提示 若使用SwipeRefreshLayout有这样的需要:只需要上面一部分布局有下拉刷新的效果,SwipeRefreshLayout的高度不要使用wrap__content,

要指定固定高度,否则会被子布局填充整个屏幕。

SwipeRefreshLayout的高度测量

原文:http://www.cnblogs.com/fajieyefu/p/5536612.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!