android.support.v7.widget.GridLayoutManager.getSpanCount()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中android.support.v7.widget.GridLayoutManager.getSpanCount()方法的一些代码示例,展示了GridLayoutManager.getSpanCount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridLayoutManager.getSpanCount()方法的具体详情如下:
包路径:android.support.v7.widget.GridLayoutManager
类名称:GridLayoutManager
方法名:getSpanCount

GridLayoutManager.getSpanCount介绍

[英]Returns the number of spans laid out by this grid.
[中]返回此网格布置的跨距数。

代码示例

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@Override
 public int getSpanSize(int position) {
  return (0 == position) ? mGridLayoutManager.getSpanCount() : 1;
 }
});

代码示例来源:origin: jdsjlzx/LRecyclerView

@Override
  public int getSpanSize(GridLayoutManager gridLayoutManager, int position) {
    if (position == 3) {
      return gridLayoutManager.getSpanCount();
    } else if (position == 7 ) {
      return gridLayoutManager.getSpanCount() - 1;
    } else {
      return 1;
    }
  }
});

代码示例来源:origin: dinuscxj/RecyclerRefreshLayout

@Override
public int getSpanSize(int position) {
 boolean isHeaderOrFooter =
   isHeaderPosition(position) || isFooterPosition(position);
 return isHeaderOrFooter ? layoutManager.getSpanCount() : 1;
}

代码示例来源:origin: jdsjlzx/LRecyclerView

@Override
public int getSpanCount() {
  return layoutManager.getSpanCount();
}

代码示例来源:origin: jdsjlzx/LRecyclerView

@Override
  public int getSpanSize(GridLayoutManager gridLayoutManager, int position) {
    Object item = mVisitables.get(position);
    return (item instanceof HotList || item instanceof ProductList || item instanceof Category) ? gridLayoutManager.getSpanCount() : 1;
  }
});

代码示例来源:origin: zhihu/Matisse

private int getImageResize(Context context) {
  if (mImageResize == 0) {
    RecyclerView.LayoutManager lm = mRecyclerView.getLayoutManager();
    int spanCount = ((GridLayoutManager) lm).getSpanCount();
    int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
    int availableWidth = screenWidth - context.getResources().getDimensionPixelSize(
        R.dimen.media_grid_spacing) * (spanCount - 1);
    mImageResize = availableWidth / spanCount;
    mImageResize = (int) (mImageResize * mSelectionSpec.thumbnailScale);
  }
  return mImageResize;
}

代码示例来源:origin: smuyyh/BookReader

private int getSpanCount(RecyclerView parent) {
  // 列数
  int spanCount = -1;
  RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
  if (layoutManager instanceof GridLayoutManager) {
    spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
  } else if (layoutManager instanceof StaggeredGridLayoutManager) {
    spanCount = ((StaggeredGridLayoutManager) layoutManager)
        .getSpanCount();
  }
  return spanCount;
}

代码示例来源:origin: jdsjlzx/LRecyclerView

private int getSpanCount(RecyclerView parent) {
  // 列数
  int spanCount = -1;
  RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
  if (layoutManager instanceof GridLayoutManager) {
    spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
  } else if (layoutManager instanceof StaggeredGridLayoutManager) {
    spanCount = ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
  }
  return spanCount;
}

代码示例来源:origin: jdsjlzx/LRecyclerView

private int getSpanCount(RecyclerView parent) {
  // 列数
  int spanCount = -1;
  LayoutManager layoutManager = parent.getLayoutManager();
  if (layoutManager instanceof GridLayoutManager) {
    spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
  } else if (layoutManager instanceof StaggeredGridLayoutManager) {
    spanCount = ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
  }
  return spanCount;
}

代码示例来源:origin: Rukey7/MvpApp

@Override
  public int getSpanSize(int position) {
    int type = getItemViewType(position);
    return (type == EMPTY_VIEW || type == HEADER_VIEW || type == FOOTER_VIEW || type == LOADING_VIEW) ? gridManager.getSpanCount() : 1;
  }
});

代码示例来源:origin: Rukey7/MvpApp

private int getSpanCount(RecyclerView parent) {
  // 列数
  int spanCount = -1;
  LayoutManager layoutManager = parent.getLayoutManager();
  if (layoutManager instanceof GridLayoutManager) {
    spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
  } else if (layoutManager instanceof StaggeredGridLayoutManager) {
    spanCount = ((StaggeredGridLayoutManager) layoutManager)
        .getSpanCount();
  }
  return spanCount;
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

@Override
  public int getSpanSize(int position) {
    WrapperAdapter wrapperAdapter = (WrapperAdapter) recyclerView.getAdapter();
    if (isFullSpanType(wrapperAdapter.getItemViewType(position))) {
      return gridLayoutManager.getSpanCount();
    }
    return 1;
  }
});

代码示例来源:origin: jdsjlzx/LRecyclerView

private int getSpanCount(RecyclerView parent) {
  // 列数
  int spanCount = -1;
  LayoutManager layoutManager = parent.getLayoutManager();
  if (layoutManager instanceof GridLayoutManager) {
    spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
  } else if (layoutManager instanceof StaggeredGridLayoutManager) {
    spanCount = ((StaggeredGridLayoutManager) layoutManager).getSpanCount();
  }
  return spanCount;
}

代码示例来源:origin: Rukey7/MvpApp

@Override
  public int getSpanSize(int position) {
    int type = getItemViewType(position);
    return (type == EMPTY_VIEW || type == HEADER_VIEW || type == FOOTER_VIEW || type == LOADING_VIEW
        || type == FULL_VIEW || type == FULL_VIEW_2 || type == FULL_VIEW_3) ? gridManager.getSpanCount() : 1;
  }
});

代码示例来源:origin: Aspsine/SwipeToLoadLayout

@Override
  public int getSpanSize(int position) {
    RecyclerView.Adapter adapter = recyclerView.getAdapter();
    if (isFullSpanType(adapter.getItemViewType(position))) {
      return gridLayoutManager.getSpanCount();
    }
    return 1;
  }
});

代码示例来源:origin: jdsjlzx/LRecyclerView

@Override
  public int getSpanSize(GridLayoutManager gridLayoutManager, int position) {
    MultipleItem item = mShopAdapter.getDataList().get(position);
    if (item.getItemType() == MultipleItem.LIST) {
      return gridLayoutManager.getSpanCount();
    } else {
      return 1;
    }
  }
});

代码示例来源:origin: facebook/litho

@Override
public ViewportFiller createViewportFiller(int measuredWidth, int measuredHeight) {
 return new ViewportFiller(
   measuredWidth, measuredHeight, getScrollDirection(), mGridLayoutManager.getSpanCount());
}

代码示例来源:origin: facebook/litho

@Override
 public int getSpanSize(int position) {
  if (mRenderInfoCollection == null) {
   return 1;
  }
  final RenderInfo renderInfo = mRenderInfoCollection.getRenderInfoAt(position);
  if (renderInfo.isFullSpan()) {
   return mGridLayoutManager.getSpanCount();
  }
  return renderInfo.getSpanSize();
 }
}

代码示例来源:origin: jdsjlzx/LRecyclerView

@Override
  public int getSpanSize(int position) {
    if (mSpanSizeLookup == null) {
      return (isHeader(position) || isFooter(position))
          ? gridManager.getSpanCount() : 1;
    } else {
      return (isHeader(position) || isFooter(position))
          ? gridManager.getSpanCount() : mSpanSizeLookup.getSpanSize(gridManager, (position - (getHeaderViewsCount() + 1)));
    }
  }
});

代码示例来源:origin: jdsjlzx/LRecyclerView

@Override
  public int getSpanSize(int position) {
    if (mSpanSizeLookup == null) {
      return (isHeader(position) || isFooter(position) || isRefreshHeader(position))
          ? gridManager.getSpanCount() : 1;
    } else {
      return (isHeader(position) || isFooter(position) || isRefreshHeader(position))
          ? gridManager.getSpanCount() : mSpanSizeLookup.getSpanSize(gridManager,  (position - (getHeaderViewsCount() + 1)));
    }
  }
});

相关文章