我对 android 很陌生,我正在探索谷歌网站上的示例代码。我目前使用的代码是 SwipeRefreshLayout:http: //developer.android.com/samples/SwipeRefreshLayoutBasic/index.html
在代码中,我们看到 SwipeRefreshLayout 正在为一个列表视图执行,也就是说,如果你向下拖动列表视图,就会触发该方法并且列表视图会自行刷新。
<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>
令我困惑的是,当您将其向下拖动时,进度动画栏的代码中没有显示在列表视图顶部的布局。你以为 SwipeRefreshLayout 在你往下拉的时候会自动生成一个进度动画条,而不需要用户在 xml 中为它指定任何布局吗?
例如,如果想在进度动画条的两端添加 padding,以使刷新时动画不会触及屏幕的两端,该怎么做呢?
https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html并没有真正说明它。