2015-04-22 4 views
0

У меня есть RecyclerView с GridLayoutManager и при использовании SwipeRefreshLayoutRecyclerView не снесен. Как создать эффект наличия зазора между панелью и recyclerview при освежении?SwipeRefreshLayout - RecyclerView не сбрасывается

XML:

<ProgressBar 
     android:id="@+id/progressBar" 
     style="?android:attr/progressBarStyleLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" /> 

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

     <RecyclerView 
      android:id="@+id/gridView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

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

</FrameLayout> 

КОД:

swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container); 
swipeLayout.setOnRefreshListener(this); 
swipeLayout.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); 

gridView = (RecyclerView) getActivity().findViewById(R.id.gridView); 
gridLayoutManager = new GridLayoutManager(getActivity(), 4, GridLayoutManager.VERTICAL, false); 
gridView.setLayoutManager(gridLayoutManager); 
gridView.setVisibility(View.GONE); 
gridView.setHasFixedSize(false); 
gridView.setItemAnimator(new DefaultItemAnimator()); 
+0

Что у вас пробовали? может быть вставить ваш код макета xml? –

+0

Я отправил код, но это простейшая реализация с обоими этими двумя представлениями. Я думаю, что проблема находится в GridLayoutManager, но я не уверен, что – mobilepotato7

+0

это помогает? http://stackoverflow.com/questions/25178329/recyclerview-and-swiperefreshlayout –

ответ

2

Ваш код все в порядке, но swipeRefreshLayout не тянет вниз вид сетки, но только сам, для демонстрационной проверки это video. Однако вы можете использовать другие библиотеки, например Ulta-Pull-to-Refresh, для достижения желаемого эффекта!

Смежные вопросы