列表Item間的間距動態調整
一、動態測量出創建的列表的高度並給它設置上下間距
**注:**contentViewHolder.llExpertClassifyContainer 爲在adapter中引用的控件名稱,此處可以根據需要調整成自己需要的view
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) contentViewHolder.llExpertClassifyContainer.getLayoutParams();
lp.topMargin = -10;
contentViewHolder.llExpertClassifyContainer.requestLayout();
如果這個列表的內容爲空,你想隱藏該模塊,可以這樣設置
RecyclerView.LayoutParams lps = new RecyclerView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, 0);
contentViewHolder.llExpertClassifyContainer.setLayoutParams(lps);
動態改變內部佈局間的padding高度間距
contentViewHolder.llExpertClassifyContainer.setPadding(0,0,0,0);