本文整理匯總了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();
}
示例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);
}
}
示例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 {
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例14: generateLayoutParams
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public RecyclerView.LayoutParams generateLayoutParams(Context c, AttributeSet attrs) {
return new InflateLayoutParams(c, attrs);
}