動態清除Item的間距 topMargin和bottomMargin

列表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);

此處僅供日常開發記錄,僅供參考

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章