2017-08-07 33 views
0

イム、センター最初の項目(GridLayoutManager)

GridLayoutManager gridLayoutManager = new GridLayoutManager(recyclerViewHolder.recyclerView.getContext(), 2); 
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { 
         @Override 
         public int getSpanSize(int position) { 
          if (position == 0&&questionsAndAnswersChatModel.get(position).getAnswers().size()%2!=0) { 
           return 2; 
          } 
          return 1; 
         } 
        }); 
+0

layout_gravity = centerパラメータを追加し、それを中心にその問題は何ですか? – umuieme

+0

最初の項目を中心にしていません – Dude

+0

何をアダプターに渡していますか? questionsAndswersChatModelまたはその回答? – umuieme

答えて

0

上記のコードでは、最初の行の一つだけのアイテムを挿入しますしかし、あなたのRecyclerView

<RecyclerView 
... 
android:layout_gravity="center_horizontal" 
android:layout_width="wrap_content" 
.../> 
+0

これはまだ動作しません – Dude

関連する問題