本文整理了Java中android.support.v7.widget.GridLayoutManager.getOrientation()
方法的一些代码示例,展示了GridLayoutManager.getOrientation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridLayoutManager.getOrientation()
方法的具体详情如下:
包路径:android.support.v7.widget.GridLayoutManager
类名称:GridLayoutManager
方法名:getOrientation
暂无
代码示例来源:origin: facebook/litho
@Override
public int getScrollDirection() {
return mGridLayoutManager.getOrientation();
}
代码示例来源:origin: facebook/litho
@Override
public int approximateRangeSize(
int firstMeasuredItemWidth,
int firstMeasuredItemHeight,
int recyclerMeasuredWidth,
int recyclerMeasuredHeight) {
final int spanCount = mGridLayoutManager.getSpanCount();
switch (mGridLayoutManager.getOrientation()) {
case GridLayoutManager.HORIZONTAL:
final int colCount = (int) Math.ceil(
(double) recyclerMeasuredWidth / (double) firstMeasuredItemWidth);
return colCount * spanCount;
default:
final int rowCount = (int) Math.ceil(
(double) recyclerMeasuredHeight / (double) firstMeasuredItemHeight);
return rowCount * spanCount;
}
}
代码示例来源:origin: facebook/litho
@Override
public int computeWrappedHeight(int maxHeight, List<ComponentTreeHolder> componentTreeHolders) {
final int itemCount = componentTreeHolders.size();
final int spanCount = mGridLayoutManager.getSpanCount();
int measuredHeight = 0;
switch (mGridLayoutManager.getOrientation()) {
case GridLayoutManager.VERTICAL:
for (int i = 0; i < itemCount; i += spanCount) {
final ComponentTreeHolder holder = componentTreeHolders.get(i);
int firstRowItemHeight = holder.getMeasuredHeight();
measuredHeight += firstRowItemHeight;
measuredHeight += LayoutInfoUtils.getTopDecorationHeight(mGridLayoutManager, i);
measuredHeight += LayoutInfoUtils.getBottomDecorationHeight(mGridLayoutManager, i);
if (measuredHeight > maxHeight) {
measuredHeight = maxHeight;
break;
}
}
return measuredHeight;
case GridLayoutManager.HORIZONTAL:
default:
throw new IllegalStateException(
"This method should only be called when orientation is vertical");
}
}
代码示例来源:origin: smuyyh/BookReader
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
int orientation = 0;
int headerCount = 0,footerCount = 0;
if (parent.getAdapter() instanceof RecyclerArrayAdapter){
headerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getHeaderCount();
footerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getFooterCount();
}
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof StaggeredGridLayoutManager){
orientation = ((StaggeredGridLayoutManager) layoutManager).getOrientation();
}else if (layoutManager instanceof GridLayoutManager){
orientation = ((GridLayoutManager) layoutManager).getOrientation();
}else if (layoutManager instanceof LinearLayoutManager){
orientation = ((LinearLayoutManager) layoutManager).getOrientation();
}
if (position>=headerCount&&position<parent.getAdapter().getItemCount()-footerCount||mDrawHeaderFooter){
if (orientation == OrientationHelper.VERTICAL){
outRect.bottom = mHeight;
}else {
outRect.right = mHeight;
}
}
}
代码示例来源:origin: smuyyh/BookReader
orientation = ((StaggeredGridLayoutManager) layoutManager).getOrientation();
}else if (layoutManager instanceof GridLayoutManager){
orientation = ((GridLayoutManager) layoutManager).getOrientation();
}else if (layoutManager instanceof LinearLayoutManager){
orientation = ((LinearLayoutManager) layoutManager).getOrientation();
代码示例来源:origin: smuyyh/BookReader
spanIndex = ((StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams()).getSpanIndex();
}else if (layoutManager instanceof GridLayoutManager){
orientation = ((GridLayoutManager) layoutManager).getOrientation();
spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
spanIndex = ((GridLayoutManager.LayoutParams) view.getLayoutParams()).getSpanIndex();
代码示例来源:origin: facebook/litho
/**
* @param widthSpec the widthSpec used to measure the parent {@link RecyclerSpec}.
* @return widthSpec of a child that is of span size 1
*/
@Override
public int getChildWidthSpec(int widthSpec, RenderInfo renderInfo) {
switch (mGridLayoutManager.getOrientation()) {
case GridLayoutManager.HORIZONTAL:
return SizeSpec.makeSizeSpec(0, UNSPECIFIED);
default:
Integer overrideWidth =
(Integer) renderInfo.getCustomAttribute(GridLayoutInfo.OVERRIDE_SIZE);
if (overrideWidth != null) {
return SizeSpec.makeSizeSpec(overrideWidth, EXACTLY);
}
if (renderInfo.isFullSpan()) {
return SizeSpec.makeSizeSpec(SizeSpec.getSize(widthSpec), EXACTLY);
}
final int spanCount = mGridLayoutManager.getSpanCount();
final int spanSize = renderInfo.getSpanSize();
return SizeSpec.makeSizeSpec(
spanSize * ((SizeSpec.getSize(widthSpec)) / spanCount), EXACTLY);
}
}
代码示例来源:origin: facebook/litho
/**
* @param heightSpec the heightSpec used to measure the parent {@link RecyclerSpec}.
* @return heightSpec of a child that is of span size 1
*/
@Override
public int getChildHeightSpec(int heightSpec, RenderInfo renderInfo) {
switch (mGridLayoutManager.getOrientation()) {
case GridLayoutManager.HORIZONTAL:
Integer overrideHeight =
(Integer) renderInfo.getCustomAttribute(GridLayoutInfo.OVERRIDE_SIZE);
if (overrideHeight != null) {
return SizeSpec.makeSizeSpec(overrideHeight, EXACTLY);
}
if (renderInfo.isFullSpan()) {
return SizeSpec.makeSizeSpec(SizeSpec.getSize(heightSpec), EXACTLY);
}
final int spanCount = mGridLayoutManager.getSpanCount();
final int spanSize = renderInfo.getSpanSize();
return SizeSpec.makeSizeSpec(
spanSize * (SizeSpec.getSize(heightSpec) / spanCount), EXACTLY);
default:
return SizeSpec.makeSizeSpec(0, UNSPECIFIED);
}
}
代码示例来源:origin: blipinsk/RecyclerViewHeader
public final boolean isVertical() {
if (linear != null) {
return linear.getOrientation() == LinearLayoutManager.VERTICAL;
} else if (grid != null) {
return grid.getOrientation() == LinearLayoutManager.VERTICAL;
// } else if (staggeredGrid != null) {
// return ; //TODO: 05.04.2016 implement staggered
}
return false; //shouldn't get here
}
}
代码示例来源:origin: iielse/ImageWatcher
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
final RecyclerView.LayoutManager manager = parent.getLayoutManager();
final int childPosition = parent.getChildAdapterPosition(view);
final int itemCount = parent.getAdapter().getItemCount();
if (manager != null) {
if (manager instanceof GridLayoutManager) {
setGrid(((GridLayoutManager) manager).getOrientation(), ((GridLayoutManager) manager).getSpanCount(), outRect, childPosition, itemCount);
} else if (manager instanceof LinearLayoutManager) {
setLinear(((LinearLayoutManager) manager).getOrientation(), outRect, childPosition, itemCount);
}
}
}
代码示例来源:origin: BoBoMEe/Android-Demos
@Override public void onChange() {
if (null != mGridLayoutManager) {
int orientation = mGridLayoutManager.getOrientation();
mGridLayoutManager.setOrientation(
orientation == GridLayoutManager.VERTICAL ? GridLayoutManager.HORIZONTAL
: GridLayoutManager.VERTICAL);
}
}
代码示例来源:origin: BoBoMEe/Android-Demos
@Override public void onChange() {
if (null != mGridLayoutManager) {
int orientation = mGridLayoutManager.getOrientation();
mGridLayoutManager.setOrientation(
orientation == GridLayoutManager.VERTICAL ? GridLayoutManager.HORIZONTAL
: GridLayoutManager.VERTICAL);
}
}
代码示例来源:origin: open-android/BaseRecyclerAndAdapter
public final boolean isVertical() {
if (linear != null) {
return linear.getOrientation() == LinearLayoutManager.VERTICAL;
} else if (grid != null) {
return grid.getOrientation() == LinearLayoutManager.VERTICAL;
// } else if (staggeredGrid != null) {
// return ; //TODO: 05.04.2016 implement staggered
}
return false; //shouldn't get here
}
}
代码示例来源:origin: BoBoMEe/Android-Demos
@Override public void onChange() {
if (null != mGridLayoutManager) {
int orientation = mGridLayoutManager.getOrientation();
mGridLayoutManager.setOrientation(
orientation == GridLayoutManager.VERTICAL ? GridLayoutManager.HORIZONTAL
: GridLayoutManager.VERTICAL);
}
}
代码示例来源:origin: mengzhidaren/RecylerViewMultiHeaderView
public final boolean isVertical() {
if (linear != null) {
return linear.getOrientation() == LinearLayoutManager.VERTICAL;
} else if (grid != null) {
return grid.getOrientation() == LinearLayoutManager.VERTICAL;
// } else if (staggeredGrid != null) {
// return ; //TODO: 05.04.2016 implement staggered
}
return false; //shouldn't get here
}
}
代码示例来源:origin: BoBoMEe/Android-Demos
@Override public void onChange() {
if (null != mGridLayoutManager) {
int orientation = mGridLayoutManager.getOrientation();
mGridLayoutManager.setOrientation(
orientation == GridLayoutManager.VERTICAL ? GridLayoutManager.HORIZONTAL
: GridLayoutManager.VERTICAL);
}
}
代码示例来源:origin: open-android/BaseRecyclerAndAdapter
public final boolean isVertical() {
if (linear != null) {
return linear.getOrientation() == LinearLayoutManager.VERTICAL;
} else if (grid != null) {
return grid.getOrientation() == LinearLayoutManager.VERTICAL;
// } else if (staggeredGrid != null) {
// return ; //TODO: 05.04.2016 implement staggered
}
return false; //shouldn't get here
}
}
代码示例来源:origin: DavidPacioianu/TheGreatAdapter
@SuppressWarnings("all")
protected int getOrientation(RecyclerView parent) {
RecyclerView.LayoutManager mgr = parent.getLayoutManager();
if (mgr instanceof LinearLayoutManager) {
return ((LinearLayoutManager) mgr).getOrientation();
} else if (mgr instanceof GridLayoutManager) {
return ((GridLayoutManager) mgr).getOrientation();
} else if (mgr instanceof StaggeredGridLayoutManager) {
return ((StaggeredGridLayoutManager) mgr).getOrientation();
}
return VERTICAL;
}
代码示例来源:origin: vihuela/RAD
@SuppressWarnings("all")
protected int getOrientation(RecyclerView parent) {
RecyclerView.LayoutManager mgr = parent.getLayoutManager();
if (mgr instanceof LinearLayoutManager) {
return ((LinearLayoutManager) mgr).getOrientation();
} else if (mgr instanceof GridLayoutManager) {
return ((GridLayoutManager) mgr).getOrientation();
} else if (mgr instanceof StaggeredGridLayoutManager) {
return ((StaggeredGridLayoutManager) mgr).getOrientation();
}
return VERTICAL;
}
代码示例来源:origin: Tencent/RapidView
private void updateMeasurements() {
int totalSpace;
if (getOrientation() == VERTICAL) {
totalSpace = getWidth() - getPaddingRight() - getPaddingLeft();
} else {
totalSpace = getHeight() - getPaddingBottom() - getPaddingTop();
}
mSizePerSpan = totalSpace / mSpanCount;
}
内容来源于网络,如有侵权,请联系作者删除!