SwipeRefreshLayout:刷卡进度动画 [英] SwipeRefreshLayout: Swipe progress animation

查看:484
本文介绍了SwipeRefreshLayout:刷卡进度动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是很新的Andr​​oid和我探讨关于谷歌网站上的样品code。在code我对目前的SwipeRefreshLayout:<一href="http://developer.android.com/samples/SwipeRefreshLayoutBasic/index.html">http://developer.android.com/samples/SwipeRefreshLayoutBasic/index.html

I'm quite new to android and I'm exploring the sample code on google website. The code I'm on currently is the SwipeRefreshLayout: http://developer.android.com/samples/SwipeRefreshLayoutBasic/index.html

在code,我们看到了SwipeRefreshLayout的列表视图执行,所以换句话说,如果向下拖动列表视图中,该方法被触发,列表视图刷新本身。

In the code, we see the SwipeRefreshLayout being executed for a listview, so in other words, if you drag down the list view, the method is triggered and the listview refreshes itself.

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

    <ListView
          android:id="@android:id/list"
          android:layout_width="match_parent"
          android:layout_height="match_parent" />

</android.support.v4.widget.SwipeRefreshLayout>

什么是困惑我的是,有在code对于被显示在当你向下拖动列表视图顶部的进度动画条没有布局。难道你认为SwipeRefreshLayout自动生成当您将它放下,而不需要用户指定在XML中的任何布局进度动画吧?

What is confusing me is that there is no layout in the code for the progress animation bar that gets displayed at the top of the listview when you drag it down. Do you think that the SwipeRefreshLayout automatically generates a progress animation bar when you drag it down without requiring the user to specify any layout in xml for it?

例如,如果一个人想要把填充的进度动画条的两端,使动画不接触,当您刷新屏幕的两端,如何将一个做到这一点?

For example, if one wants to put padding at both ends of the progress animation bar, so that the animation doesn't touch the ends of the screen when you refresh, how would one do it?

的<一个href="https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html">https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html并没有真正说什么。

推荐答案

不可以更改动画。

SwipeRefreshLayout 您不能自定义多;我相信这是谷歌的一个企图让开发商坚持共同的模式。你可以风格是什么四种颜色的动画,用 setColorScheme规定()

In SwipeRefreshLayout you can't customize much; I believe this is an attempt of Google to get developers stick to common patterns. What you can style are the four colors of the animation, specified with setColorScheme().

SwipeRefreshLayout 照顾,以显示其predefined动画在其顶部为您服务。这可能是在 canChildScrollUp()返回false和用户拉下来,或者当您设置 setRefreshing(真) 。关闭动画 setRefreshing(假)。把你的逻辑在听者的方法 onRefreshing()。覆盖 canChildScrollUp()如果你把东西是不是的ListView SwipeRefreshLayout 。你要善于从这里走。

SwipeRefreshLayout takes care to show its predefined animation at its top for you. This can be when canChildScrollUp() returns false and user 'pulls down', or when you set setRefreshing(true). Turn off the animation with setRefreshing(false). Put your logic in the method onRefreshing() of the listener. Override canChildScrollUp() if you put something that is not a ListView in your SwipeRefreshLayout. You should be good to go from here.

这篇关于SwipeRefreshLayout:刷卡进度动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆