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


Java RecyclerView.LayoutParams方法代碼示例

本文整理匯總了Java中android.support.v7.widget.RecyclerView.LayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.LayoutParams方法的具體用法?Java RecyclerView.LayoutParams怎麽用?Java RecyclerView.LayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.RecyclerView的用法示例。


在下文中一共展示了RecyclerView.LayoutParams方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleStateOnResult

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected void handleStateOnResult(LayoutChunkResult result, View view) {
    if (view == null) {
        return;
    }

    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();

    // Consume the available space if the view is not removed OR changed
    if (params.isItemRemoved() || params.isItemChanged()) {
        result.mIgnoreConsumed = true;
    }

    // used when search a focusable view
    result.mFocusable = result.mFocusable || view.isFocusable();

}
 
開發者ID:alibaba,項目名稱:vlayout,代碼行數:17,代碼來源:BaseLayoutHelper.java

示例2: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        android.support.v7.widget.RecyclerView v = new android.support.v7.widget.RecyclerView(parent.getContext());
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:BittleDragon,項目名稱:MyRepository,代碼行數:17,代碼來源:DividerItemDecoration.java

示例3: measureScrapChild

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
                               int heightSpec, int[] measuredDimension) {
    try {
        View view = recycler.getViewForPosition(0);//fix 動態添加時報IndexOutOfBoundsException

        if (view != null) {
            RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();

            int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec,
                    getPaddingLeft() + getPaddingRight(), p.width);

            int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec,
                    getPaddingTop() + getPaddingBottom(), p.height);

            view.measure(childWidthSpec, childHeightSpec);
            measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin;
            measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin;
            recycler.recycleView(view);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:FullyLinearLayoutManager.java

示例4: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent) {
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);

        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getTop() - params.topMargin;
        final int bottom = child.getBottom() + params.bottomMargin;
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicWidth();

        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:17,代碼來源:DividerGridItemDecoration.java

示例5: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        if (!needDrawDecoration(parent, i)) {
            continue;
        }
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:19,代碼來源:DividerItemDecoration.java

示例6: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * Draw dividers at each expected grid interval
 */
public void drawVertical(Canvas c, RecyclerView parent) {
    if (parent.getChildCount() == 0) return;

    final int childCount = parent.getChildCount();

    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params =
                (RecyclerView.LayoutParams) child.getLayoutParams();

        final int left = child.getLeft() - params.leftMargin - mInsets;
        final int right = child.getRight() + params.rightMargin + mInsets;
        final int top = child.getBottom() + params.bottomMargin + mInsets;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:22,代碼來源:GridDividerDecoration.java

示例7: drawVertical

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawVertical(Canvas c, RecyclerView parent) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:xinpianchang,項目名稱:NSMPlayer-Android,代碼行數:16,代碼來源:DividerItemDecoration.java

示例8: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:OCNYang,項目名稱:RecyclerViewEvent,代碼行數:16,代碼來源:DividerListItemDecoration.java

示例9: getRecyclerViewItemTopInset

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 通過反射獲取RecyclerView的item的topInset
 *
 * @param layoutParams
 * @return
 */
private static int getRecyclerViewItemTopInset(RecyclerView.LayoutParams layoutParams) {
    try {
        Field field = RecyclerView.LayoutParams.class.getDeclaredField("mDecorInsets");
        field.setAccessible(true);
        // 開發者自定義的滾動監聽器
        Rect decorInsets = (Rect) field.get(layoutParams);
        return decorInsets.top;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0;
}
 
開發者ID:Justson,項目名稱:AgentWebX5,代碼行數:19,代碼來源:ScrollingUtil.java

示例10: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin +
                Math.round(ViewCompat.getTranslationX(child));
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:16,代碼來源:DividerItemDecoration.java

示例11: drawHorizontal

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    int childCount = parent.getChildCount();

    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
開發者ID:ymqq,項目名稱:CommonFramework,代碼行數:16,代碼來源:DividerItemDecoration.java

示例12: drawHorizontalOrientationDividers

import android.support.v7.widget.RecyclerView; //導入方法依賴的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

示例13: generateDefaultLayoutParams

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public RecyclerView.LayoutParams generateDefaultLayoutParams() {
    return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
}
 
開發者ID:HYY-yu,項目名稱:TableRecyclerView,代碼行數:6,代碼來源:TableLayoutManager.java

示例14: generateLayoutParams

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public RecyclerView.LayoutParams generateLayoutParams(Context c, AttributeSet attrs) {
    return new InflateLayoutParams(c, attrs);
}
 
開發者ID:alibaba,項目名稱:vlayout,代碼行數:5,代碼來源:VirtualLayoutManager.java


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