本文整理汇总了Java中android.support.v7.widget.LinearLayoutManager.getReverseLayout方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayoutManager.getReverseLayout方法的具体用法?Java LinearLayoutManager.getReverseLayout怎么用?Java LinearLayoutManager.getReverseLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.LinearLayoutManager
的用法示例。
在下文中一共展示了LinearLayoutManager.getReverseLayout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawHorizontalOrientationDividers
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
void drawHorizontalOrientationDividers(Canvas c, RecyclerView parent,
RecyclerView.LayoutManager layoutManager) {
LinearLayoutManager manager = (LinearLayoutManager) layoutManager;
int childCount = parent.getChildCount();
float left, top, right, bottom;
for (int i = 0; i < childCount; i++) {
View view = parent.getChildAt(i);
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) view.getLayoutParams();
int position = lp.getViewAdapterPosition();
if (position < 0 || !mProvider.isDividerNeedDraw(position))
continue;
float transitionX = ViewCompat.getTranslationX(view);
float transitionY = ViewCompat.getTranslationY(view);
top = view.getTop() - lp.topMargin + transitionY + mProvider.marginStart(position);
bottom = view.getBottom() + lp.bottomMargin + transitionY - mProvider.marginEnd(position);
IDivider divider = mProvider.createDivider(position);
if (manager.getReverseLayout()) {
if (divider.getType() == IDivider.TYPE_DRAWABLE) {
right = view.getLeft() - lp.leftMargin + transitionX;
left = right - divider.getDividerSize();
} else {
left = view.getLeft() - lp.leftMargin - divider.getDividerSize() / 2f + transitionY;
right = left;
}
if (mDrawInsideEachOfItem) {
left += divider.getDividerSize();
right += divider.getDividerSize();
}
} else {
if (divider.getType() == IDivider.TYPE_DRAWABLE) {
left = view.getRight() + lp.rightMargin + transitionX;
right = left + divider.getDividerSize();
} else {
left = view.getRight() + lp.rightMargin + divider.getDividerSize() / 2f + transitionX;
right = left;
}
if (mDrawInsideEachOfItem) {
left -= divider.getDividerSize();
right -= divider.getDividerSize();
}
}
divider.draw(c, left, top, right, bottom);
}
}
示例2: calculateItemOffsets
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
void calculateItemOffsets(RecyclerView parent, int position, Rect rect) {
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (!(layoutManager instanceof LinearLayoutManager)) {
throw new UnsupportedOperationException("LinearItemDecoration can only be used in " +
"the RecyclerView which use LinearLayoutManager");
}
if (mDrawInsideEachOfItem) {
rect.set(0, 0, 0, 0);
return;
}
LinearLayoutManager manager = (LinearLayoutManager) layoutManager;
if (manager.getOrientation() == OrientationHelper.VERTICAL) {
if (manager.getReverseLayout()) {
if (mProvider.isDividerNeedDraw(position)) {
rect.set(0, mProvider.createDivider(position).getDividerSize(), 0, 0);
} else {
rect.set(0, 0, 0, 0);
}
} else {
if (mProvider.isDividerNeedDraw(position)) {
rect.set(0, 0, 0, mProvider.createDivider(position).getDividerSize());
} else {
rect.set(0, 0, 0, 0);
}
}
} else {
if (manager.getReverseLayout()) {
if (mProvider.isDividerNeedDraw(position)) {
rect.set(mProvider.createDivider(position).getDividerSize(), 0, 0, 0);
} else {
rect.set(0, 0, 0, 0);
}
} else {
if (mProvider.isDividerNeedDraw(position)) {
rect.set(0, 0, mProvider.createDivider(position).getDividerSize(), 0);
} else {
rect.set(0, 0, 0, 0);
}
}
}
}
示例3: drawVerticalOrientationDividers
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
void drawVerticalOrientationDividers(Canvas c, RecyclerView parent,
RecyclerView.LayoutManager layoutManager) {
LinearLayoutManager manager = (LinearLayoutManager) layoutManager;
int childCount = parent.getChildCount();
float left, top, right, bottom;
for (int i = 0; i < childCount; i++) {
View view = parent.getChildAt(i);
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) view.getLayoutParams();
int position = lp.getViewAdapterPosition();
if (position < 0 || !mProvider.isDividerNeedDraw(position))
continue;
float transitionX = ViewCompat.getTranslationX(view);
float transitionY = ViewCompat.getTranslationY(view);
left = view.getLeft() - lp.leftMargin + transitionX + mProvider.marginStart(position);
right = view.getRight() + lp.rightMargin + transitionX - mProvider.marginEnd(position);
IDivider divider = mProvider.createDivider(position);
if (manager.getReverseLayout()) {
if (divider.getType() == IDivider.TYPE_DRAWABLE) {
bottom = view.getTop() - lp.topMargin + transitionY;
top = bottom - divider.getDividerSize();
} else {
top = view.getTop() - lp.topMargin - divider.getDividerSize() / 2f + transitionY;
bottom = top;
}
if (mDrawInsideEachOfItem) {
top += divider.getDividerSize();
bottom += divider.getDividerSize();
}
} else {
if (divider.getType() == IDivider.TYPE_DRAWABLE) {
top = view.getBottom() + lp.bottomMargin + transitionY;
bottom = top + divider.getDividerSize();
} else {
top = view.getBottom() + lp.bottomMargin + divider.getDividerSize() / 2f + transitionY;
bottom = top;
}
if (mDrawInsideEachOfItem) {
top -= divider.getDividerSize();
bottom -= divider.getDividerSize();
}
}
divider.draw(c, left, top, right, bottom);
}
}