2017-04-24 141 views
0

我在我的主要活動2 RecyclerView s:一個是水平的,另一個是垂直的。我的問題是,當我在第二個回收站中向下滾動時,我想讓上方的回收站也滾動,但不是。它保持固定。當滾動第二個時滾動RecyclerView

這是我的代碼:

recyclerView = (RecyclerView) findViewById(R.id.recyclerview1); 
recylerViewLayoutManager = new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false); 
recyclerView.setLayoutManager(recylerViewLayoutManager); 
recyclerViewAdapter = new RecyclerViewAdapter(MainActivity.this, subjects,images); 
recyclerView.setAdapter(recyclerViewAdapter); 


MainGridRecView = (RecyclerView) findViewById(R.id.maingridrc); 
MainGridRecViewLayoutManager = new GridLayoutManager(context,2); 
MainGridRecView.setLayoutManager(MainGridRecViewLayoutManager); 
MainGridRecViewAdapter = new MainGridRecyclerViewAdapter(MainActivity.this, subjects,images); 
MainGridRecView.setAdapter(MainGridRecViewAdapter); 

回答

0

您可以添加RecyclerView.OnScrollListener和手動滾動另一RecyclerView

recyclerView1.addOnScrollListener(new RecyclerView.OnScrollListener() { 
    @Override 
    public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) { 
     recyclerView2.setScrollX(dx); 
     recyclerView2.setScrollY(dy); 
    } 
}); 

雖然我不明白你想什麼樣的影響來實現的,但至少你會得到這個概念。

+0

我有一個連接問題,我不能發佈我的完整問題無論如何生病嘗試這個,如果它不qork病解釋更多 – Moudiz