标签: swiperefreshlayout

SwipeRefreshLayout setRefreshing()最初没有显示指标

我有一个非常简单的布局,但是当我打电话setRefreshing(true)onActivityCreated()我的片段,将其最初不显示.

它只显示我何时刷新.任何想法为什么它最初没有出现?

片段xml:

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_container"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

        </RelativeLayout>


    </ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

片段代码:

public static class LinkDetailsFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {

    @InjectView(R.id.swipe_container)
    SwipeRefreshLayout mSwipeContainer;

    public static LinkDetailsFragment newInstance(String subreddit, String linkId) {
        Bundle args = new Bundle();
        args.putString(EXTRA_SUBREDDIT, subreddit);
        args.putString(EXTRA_LINK_ID, linkId);

        LinkDetailsFragment fragment = new LinkDetailsFragment();
        fragment.setArguments(args);

        return fragment;
    }

    public LinkDetailsFragment() {
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        mSwipeContainer.setOnRefreshListener(this);
        mSwipeContainer.setColorScheme(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
        mSwipeContainer.setRefreshing(true);
    } …
Run Code Online (Sandbox Code Playgroud)

android swiperefreshlayout

141
推荐指数
5
解决办法
5万
查看次数

SwipeRefreshLayout + ViewPager,仅限制水平滚动?

我实现了SwipeRefreshLayoutViewPager我的应用程序,但有一个大麻烦:每当我要去刷卡左/右滚动页面之间切换过于敏感.稍微向下滑动也会触发SwipeRefreshLayout刷新.

我想设置水平滑动开始时的限制,然后强制水平直到滑动结束.换句话说,当手指水平移动时,我想取消垂直滑动.

这个问题只发生在ViewPager,如果我向下滑动并SwipeRefreshLayout触发刷新功能(显示条形图)然后我水平移动手指,它仍然只允许垂直滑动.

我试图扩展ViewPager课程,但它根本不起作用:

public class CustomViewPager extends ViewPager {

    public CustomViewPager(Context ctx, AttributeSet attrs) {
        super(ctx, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        boolean in = super.onInterceptTouchEvent(ev);
        if (in) {
            getParent().requestDisallowInterceptTouchEvent(true);
            this.requestDisallowInterceptTouchEvent(true);
        }
        return false;
    }

}
Run Code Online (Sandbox Code Playgroud)

布局xml:

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/viewTopic"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.myapp.listloader.foundation.CustomViewPager
        android:id="@+id/topicViewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激,谢谢

android gesture android-viewpager swiperefreshlayout

89
推荐指数
5
解决办法
3万
查看次数

在刷新期间使用SwipeRefreshLayout切换片段时,片段冻结但实际上仍然有效

更新:我认为它工作正常.但经过一些测试仍然存在麻烦*嗅*

然后我做了一个更简单的版本,看看究竟发生了什么,并且我知道应该已经分离的刷新片段仍然留在那里.或者确切地说,旧片段的视图留在那里,较新的片段之上.由于RecyclerView的原始应用程序的背景不透明,所以我之前说过.

更新结束


我有这样的MainActivity布局:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_height="match_parent">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <FrameLayout android:id="@+id/container" android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- android:layout_gravity="start" tells DrawerLayout to treat
         this as a sliding drawer on the left side for left-to-right
         languages and on the right side for right-to-left languages.
         If you're not building against API 17 or higher, use
         android:layout_gravity="left" instead. --> …
Run Code Online (Sandbox Code Playgroud)

android android-fragments swiperefreshlayout android-recyclerview

72
推荐指数
2
解决办法
1万
查看次数

以编程方式触发SwipeRefreshLayout

有没有办法以SwipeRefreshLayout编程方式触发?应该启动动画,并且应该调用界面中的onRefresh方法OnRefreshListener.

java android swiperefreshlayout

59
推荐指数
2
解决办法
3万
查看次数

RecyclerView和SwipeRefreshLayout

我正在使用新RecyclerView-Layout的a SwipeRefreshLayout并经历了一种奇怪的行为.当滚动列表回到顶部时,有时顶部的视图会被切入.

列表滚动到顶部

如果我现在尝试滚动到顶部 - Pull-To-Refresh触发器.

切割的行

如果我尝试删除Recycler-View周围的Swipe-Refresh-Layout,问题就消失了.它可以在任何手机上重现(不仅仅是L-Preview设备).

 <android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/contentView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="gone">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/hot_fragment_recycler"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的布局 - 行由RecyclerViewAdapter动态构建(此列表中有2个Viewtypes).

public class HotRecyclerAdapter extends TikDaggerRecyclerAdapter<GameRow> {

private static final int VIEWTYPE_GAME_TITLE = 0;
private static final int VIEWTYPE_GAME_TEAM = 1;

@Inject
Picasso picasso;

public HotRecyclerAdapter(Injector injector) {
    super(injector);
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position, int viewType) {
    switch (viewType) {
        case VIEWTYPE_GAME_TITLE: {
            TitleGameRowViewHolder holder = (TitleGameRowViewHolder) viewHolder;
            holder.bindGameRow(picasso, getItem(position));
            break;
        }
        case VIEWTYPE_GAME_TEAM: …
Run Code Online (Sandbox Code Playgroud)

android swiperefreshlayout android-recyclerview

58
推荐指数
4
解决办法
7万
查看次数

如何禁用"拉动刷新"操作并仅使用指示器?

我使用了"启动刷新"到我的项目SwipeRefreshLayout.

当我向下移动时,出现加载指示器(材料设计样式).我知道,它必须如此工作,但我想禁用此功能,并通过单击某个按钮并使用SwipeRefreshLayout加载指示器开始刷新.

我怎么能这样做?

android pull-to-refresh swiperefreshlayout material-design

57
推荐指数
2
解决办法
3万
查看次数

Android:CollapsingToolbarLayout和SwipeRefreshLayout卡住了

我一起使用CollapsingToolbarLayout,RecyclerView和SwipeRefreshLayout:

XML:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinator_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/collapse_toolbar_height"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:contentScrim="?attr/colorPrimary"
        android:fitsSystemWindows="true"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/toolbar_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:fitsSystemWindows="true"
            app:layout_collapseMode="parallax" />

        <include
            layout="@layout/activity_main_toolbar"/>

    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <cz.yetanotherview.webcamviewer.app.helper.EmptyRecyclerView
            android:id="@+id/mainList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />
    </android.support.v4.widget.SwipeRefreshLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/floating_action_button"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        app:layout_anchor="@id/appbar"
        app:layout_anchorGravity="bottom|right|end"
        android:layout_margin="16dp"
        app:fabSize="mini"
        android:src="@drawable/ic_action_edit"
        android:onClick="assignSelectedWebCamsToCategory"/>

    <com.github.clans.fab.FloatingActionMenu
        android:id="@+id/floating_action_menu"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom|end"
        android:paddingRight="10dp"
        android:paddingBottom="8dp"
        android:paddingLeft="10dp"
        fab:menu_shadowColor="#37000000"
        fab:menu_colorNormal="#DA4336"
        fab:menu_colorPressed="#E75043"
        fab:menu_colorRipple="#99FFFFFF"
        fab:menu_icon="@drawable/fab_add"
        fab:menu_buttonSpacing="10dp"
        fab:menu_labels_textColor="@color/very_dark_grey"
        fab:menu_labels_textSize="14sp"
        fab:menu_labels_colorNormal="@color/white" …
Run Code Online (Sandbox Code Playgroud)

android swiperefreshlayout android-collapsingtoolbarlayout

56
推荐指数
3
解决办法
3万
查看次数

SwipeRefreshLayout中的Horizo​​ntalScrollView

我实现了新的SwipeRefreshLayout成分在我的应用程序,它与任何垂直意见工作得很好,比如ListView,GridViewScrollView.

它在水平视图中表现得很糟糕,比如HorizontalScrollView.向右或向左滚动时,SwipeRefreshLayout视图会缓存触摸,阻止HorizontalScrollView接收并开始垂直滚动以执行刷新.

我尝试解决这个问题,因为我之前解决了ScrollViewViewPager内部垂直问题,使用requestDisallowInterceptTouchEvent但它没有用.我还注意到,在原始SwipeRefreshLayout类中重写此方法而不返回super.谷歌的开发者留下了评论" //Nope.":)

因为SwipeRefreshLayout组件相对较新,我找不到修复水平滚动问题的解决方案,同时仍然允许滑动刷新视图以跟踪和处理垂直滚动,所以我想我会分享我的解决方案,希望它会让人节省一个小时或两个.

android horizontalscrollview swiperefreshlayout

50
推荐指数
2
解决办法
1万
查看次数

Android:CoordinatorLayout和SwipeRefreshLayout

我尝试从新的支持库22.2.0实现自动隐藏工具栏功能.没有SwipeRefreshLayout工作正常:

在此输入图像描述

但是当我重新添加此布局时,工具栏重叠了recyclerview:

在此输入图像描述

码:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:fab="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.Toolbar
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:theme="@style/ThemeOverlay.ActionBar"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_scrollFlags="scroll|enterAlways"/>

        </android.support.design.widget.AppBarLayout>

        <android.support.v4.widget.SwipeRefreshLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/swipe_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/cardList"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="vertical"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

        </android.support.v4.widget.SwipeRefreshLayout>
    </android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

知道如何解决这个问题吗?

android android-appcompat swiperefreshlayout coordinator-layout

42
推荐指数
1
解决办法
2万
查看次数

向下滑动时,SwipeRefreshLayout禁用拖动动画

是否可以SwipeRefreshLayout在没有类自定义的情况下在向下滑动时禁用拖动动画?

android swiperefreshlayout

38
推荐指数
3
解决办法
2万
查看次数