1. 程式人生 > >RecyclerView--GridLayoutManager設定某個item佔據的列數

RecyclerView--GridLayoutManager設定某個item佔據的列數

    /**
     * 設定瀑布流佈局中的某個item,獨佔一行、佔一列、佔兩列、等等
     * @param mStaggeredGridLayoutManager
* @param position 目標item所在的位置
     * @param TARGET_ITEM_TYPE 目標item的條目型別
     * @param parentView 該item的整個佈局
     */
private void setStaggeredItemSpanCount(StaggeredGridLayoutManager mStaggeredGridLayoutManager,int 
position,int TARGET_ITEM_TYPE,View parentView){ int type = getItemViewType(position); if(type == TARGET_ITEM_TYPE){ StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT
, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setFullSpan(true); parentView.setLayoutParams(layoutParams); } }