问题描述
我正在以编程方式在ViewHolder中添加TextViews,该ViewHolder已添加到RecyclerView中。我面临的问题是它到达屏幕末端并转到新行时,文本从屏幕开始处未对齐。
mHolder.mAuthorsContainer.removeAllViews();
int size = mData.mAuthors.mAuthorsHMap.size(),count = 1;
Typeface typeface = ResourcesCompat.getFont(mContext,R.font.zillaslab_bold);
for(Map.Entry<String,String> entry : mData.mAuthors.mAuthorsHMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
TextView mAuthor_ = new TextView(mContext);
mAuthor_.setTextColor(Color.parseColor("#3100A2"));
mAuthor_.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT));
mAuthor_.setTypeface(typeface);
mAuthor_.setTextSize(TypedValue.COMPLEX_UNIT_SP,CustomPreferences.getInstance(mContext).getmSpArticlePublishSize());
mAuthor_.setLinespacing(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,CustomPreferences.getInstance(mContext).getmSpArticleTextLinespacing(),mMetrics),1.0f);
mAuthor_.setText(value);
mHolder.mAuthorsContainer.addView(mAuthor_);
}
mAuthorsContainer是LinearLayout,父布局是ConstraintLayout,仅此
尝试将setLines,setMaxLines,setGravity移到左侧,到目前为止没有任何效果。
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)