當前位置: 首頁>>代碼示例>>Java>>正文


Java LinearLayoutManager.getReverseLayout方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:dkzwm,項目名稱:ItemDecorations,代碼行數:46,代碼來源:LinearItemDecoration.java

示例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);
            }
        }
    }
}
 
開發者ID:dkzwm,項目名稱:ItemDecorations,代碼行數:43,代碼來源:LinearItemDecoration.java

示例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);
    }
}
 
開發者ID:dkzwm,項目名稱:ItemDecorations,代碼行數:46,代碼來源:LinearItemDecoration.java


注:本文中的android.support.v7.widget.LinearLayoutManager.getReverseLayout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。