use*_*752 24 android swiperefreshlayout
我有以下布局
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<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:orientation="vertical" >
//some views here
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*" >
</TableLayout>
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)
问题是当我向下滚动表格时,我无法再次滚动,因为正在触发swipelayout.仅当表的第一个视图可见时,如何触发swiperefresh?
jjn*_*guy 72
我发现,如果您更换ScrollView了android.support.v4.widget.NestedScrollView,你指望它的滚动行为会奏效.
小智 8
自己实现SwipeRefreshLayout并以这种方式覆盖canChildScrollUp:
@Override
public boolean canChildScrollUp() {
if (scrollView != null)
return scrollView.canScrollVertically(-1);
return false;
}
Run Code Online (Sandbox Code Playgroud)
只需替换ScrollView的任何子类.
小智 5
如果你有这样的布局:
<SwipeRefreshLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/your_scroll_view_id">
<LinearLayout>
...
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)
您需要创建自己的类并以这种方式覆盖该函数:
class SwipeRefreshLayoutCustom extends SwipeRefreshLayout {
public SwipeRefreshLayoutCustom(Context context, AttributeSet attributes) {
super(context, attributes)
}
@override
boolean canChildScrollUp() {
return your_scroll_view_id.scrollY != 0
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16956 次 |
| 最近记录: |