SwipeRefreshLayout的高度测量
感谢此作者的分享 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,
要指定固定高度,否则会被子布局填充整个屏幕。
浙公网安备 33010602011771号