在我的recyclerview onCreateViewholder方法中,我创建了一个动态,它在线性布局中有未指定数量的文本视图
if (sessionManager.getBookScrolOrientation() == AppConstents.HORIZONTAL) {
LinearLayout linearLayout = new LinearLayout(context);
ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT , ViewGroup.LayoutParams.MATCH_PARENT);
linearLayout.setLayoutParams(layoutParams);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
Spannable spannable = getVerseSpanableHorizontal(pidreference.get(position) , cidreference.get(position));
Pagination pagination = new Pagination(spannable,
pageWidth,
pageHight,
textPaint,
lineSpacingMultiplier,
lineSpacingExtra,
isTextPaddingIncluded);
List<CharSequence> list = pagination.getPages();
for (CharSequence charSequence : list){
TextView tv = new TextView(linearLayout.getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Tools.getScreenWidth() , ViewGroup.LayoutParams.MATCH_PARENT);
tv.setLayoutParams(params);
tv.setText(charSequence);
linearLayout.addView(tv);
}
MainViewHolder viewHolder = new MainViewHolder(linearLayout);
return viewHolder;
}
当我使用SnapHelper和这个recyclelerview时,它会滚动到线性布局的中心而不是下一个textview。如何让它滚动到linearlayout中的下一个textview?
答案 0 :(得分:0)
如果我理解正确,问题是<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<input type="file" id="imageUpload" style="margin: 15px 0; display: block;" />
<div id="profile-image-preview"></div>
将当前视图的中心捕捉到回收者的中心。正如docs所说:
实现将目标子视图的中心捕捉到附加的RecyclerView的中心。
如果您希望当前视图捕捉到回收器的开头,请使用此one之类的库。用gradle导入它并像这样激活它:
SnapHelper