ActionBar后面的SwipeRefreshLayout

Fra*_*ank 35 android swiperefreshlayout

将SwipeRefreshLayout与叠加模式ActionBar结合使用时,加载动画将显示在操作栏后面,使其几乎不可见.

我可以做些什么来在动作栏上显示它吗?

Tal*_*tle 60

在appcompat-v7库(v21.0.0)的Material Design版本中,SwipeRefreshLayout获取一个设置Progress View偏移量的方法.

https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html#setProgressViewOffset(boolean,%20int,%20int)

public void setProgressViewOffset(boolean scale,int start,int end)

刷新指示器开始和静止位置始终位于刷新内容的顶部附近.此位置是一致的位置,但可以根据是否存在工具栏或操作栏在任一方向上进行调整.

参数

scale 如果没有高于z顺序的视图,则设置为true,而不是将进度微调器设置为显示的位置.

start 此视图顶部应显示进度微调器的偏移量(以像素为单位).

end 从成功滑动手势后进度微调器应该停止的此视图顶部的像素偏移量(以像素为单位).


Vij*_*put 17

试试这段代码:

int top_to_padding=100;
swipe_refresh_layout.setProgressViewOffset(false, 0,top_to_padding);
Run Code Online (Sandbox Code Playgroud)

我希望它为你工作.