2017-03-16 27 views
1

如何让视图保留在列表的开头?从Firebase加载项目后,RecyclerView正在滚动到视图的底部

我试过scrollTo(0,0)但它似乎没有工作。

编辑: 我recyclerview小鬼..

newsFeedView.setHasFixedSize(false); 
newsFeedView.setLayoutManager(
    new LinearLayoutManager(this.getActivity(), LinearLayoutManager.VERTICAL, true)); 
FirebaseRecyclerAdapter<NewsFeed, NewsFeedHolder> mAdapter; 
mAdapter = new FirebaseRecyclerAdapter<NewsFeed, NewsFeedHolder>(NewsFeed.class, 
    R.layout.item_newsfeed, NewsFeedHolder.class, 
    database.child("posts").orderByChild("timeCreated")) {...} 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/detail_comments_view" 
    android:layout_width="0dp" 
    android:layout_height="295dp" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dp" 
    android:layout_marginTop="8dp" 
    android:clickable="true" 
    android:windowSoftInputMode="adjustResize" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toBottomOf="@+id/details_cv" 
    android:layout_marginBottom="0dp" 
    app:layout_constraintBottom_toTopOf="@+id/comment_test_button" 
    /> 

让我知道如果你需要更多

+0

考虑添加一些你的鳕鱼e,所以我们可以更好地帮助你... –

+0

你确定你没有添加一些代码,使recyclerview自动滚动吗? – koceeng

+0

是的,我很确定我所有的电话都和我的电视无关 – user3875913

回答

0

我不得不改变

new LinearLayoutManager(this.getActivity(), LinearLayoutManager.VERTICAL, false)); 

,并添加

.setReverseLayout(true); 
.setStackFromEnd(true); 
相关问题