本文整理汇总了Java中android.support.v7.widget.RecyclerView.LayoutParams类的典型用法代码示例。如果您正苦于以下问题:Java LayoutParams类的具体用法?Java LayoutParams怎么用?Java LayoutParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LayoutParams类属于android.support.v7.widget.RecyclerView包,在下文中一共展示了LayoutParams类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recycleFromStart
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
private void recycleFromStart(RecyclerView.Recycler recycler, int line, LayoutManagerHelper helper) {
final OrientationHelper orientationHelper = helper.getMainOrientationHelper();
boolean changed = true;
while (helper.getChildCount() > 0 && changed) {
View child = helper.getChildAt(0);
if (child != null && orientationHelper.getDecoratedEnd(child) < line) {
LayoutParams lp = (LayoutParams) child.getLayoutParams();
int position = lp.getViewPosition();
Span span = findSpan(position, child, true);
if (span != null) {
span.popStart(orientationHelper);
helper.removeChildView(child);
recycler.recycleView(child);
} else {
changed = false;
}
} else {
return;// done
}
}
}
示例2: recycleFromEnd
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
private void recycleFromEnd(RecyclerView.Recycler recycler, int line, LayoutManagerHelper helper) {
final OrientationHelper orientationHelper = helper.getMainOrientationHelper();
final int childCount = helper.getChildCount();
int i;
for (i = childCount - 1; i >= 0; i--) {
View child = helper.getChildAt(i);
if (child != null && orientationHelper.getDecoratedStart(child) > line) {
LayoutParams lp = (LayoutParams) child.getLayoutParams();
int position = lp.getViewPosition();
Span span = findSpan(position, child, false);
if (span != null) {
span.popEnd(orientationHelper);
helper.removeChildView(child);
recycler.recycleView(child);
}
} else {
return;// done
}
}
}
示例3: recycleFromStart
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
private void recycleFromStart(RecyclerView.Recycler recycler, int line, LayoutManagerHelper helper) {
final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
boolean changed = true;
while (helper.getChildCount() > 0 && changed) {
View child = helper.getChildAt(0);
if (child != null && orientationHelper.getDecoratedEnd(child) < line) {
LayoutParams lp = (LayoutParams) child.getLayoutParams();
int position = lp.getViewPosition();
Span span = findSpan(position, child, true);
if (span != null) {
span.popStart(orientationHelper);
helper.removeChildView(child);
recycler.recycleView(child);
} else {
changed = false;
}
} else {
return;// done
}
}
}
示例4: recycleFromEnd
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
private void recycleFromEnd(RecyclerView.Recycler recycler, int line, LayoutManagerHelper helper) {
final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
final int childCount = helper.getChildCount();
int i;
for (i = childCount - 1; i >= 0; i--) {
View child = helper.getChildAt(i);
if (child != null && orientationHelper.getDecoratedStart(child) > line) {
LayoutParams lp = (LayoutParams) child.getLayoutParams();
int position = lp.getViewPosition();
Span span = findSpan(position, child, false);
if (span != null) {
span.popEnd(orientationHelper);
helper.removeChildView(child);
recycler.recycleView(child);
}
} else {
return;// done
}
}
}
示例5: nextViewInLimitedList
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
public View nextViewInLimitedList(View ignore) {
int size = this.mScrapList.size();
View closest = null;
int closestDistance = Integer.MAX_VALUE;
for (int i = 0; i < size; i++) {
View view = ((ViewHolder) this.mScrapList.get(i)).itemView;
LayoutParams lp = (LayoutParams) view.getLayoutParams();
if (!(view == ignore || lp.isItemRemoved())) {
int distance = (lp.getViewLayoutPosition() - this.mCurrentPosition) * this.mItemDirection;
if (distance >= 0 && distance < closestDistance) {
closest = view;
closestDistance = distance;
if (distance == 0) {
break;
}
}
}
}
return closest;
}
示例6: nextViewInLimitedList
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
public View nextViewInLimitedList(View ignore) {
int size = this.mScrapList.size();
View closest = null;
int closestDistance = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
for (int i = 0; i < size; i++) {
View view = ((ViewHolder) this.mScrapList.get(i)).itemView;
LayoutParams lp = (LayoutParams) view.getLayoutParams();
if (!(view == ignore || lp.isItemRemoved())) {
int distance = (lp.getViewLayoutPosition() - this.mCurrentPosition) * this.mItemDirection;
if (distance >= 0 && distance < closestDistance) {
closest = view;
closestDistance = distance;
if (distance == 0) {
break;
}
}
}
}
return closest;
}
示例7: makeAndAddView
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
private View makeAndAddView(int position, Direction direction, Recycler recycler) {
final View child = recycler.getViewForPosition(position);
final boolean isItemRemoved = ((LayoutParams) child.getLayoutParams()).isItemRemoved();
if (!isItemRemoved) {
addView(child, (direction == Direction.END ? -1 : 0));
}
setupChild(child, direction);
if (!isItemRemoved) {
updateLayoutEdgesFromNewChild(child);
}
return child;
}
示例8: layoutChild
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
@Override
protected void layoutChild(View child, Direction direction) {
getLaneForChild(mTempLaneInfo, child, direction);
mLanes.getChildFrame(mChildFrame, getDecoratedMeasuredWidth(child),
getDecoratedMeasuredHeight(child), mTempLaneInfo, direction);
final ItemEntry entry = cacheChildFrame(child, mChildFrame);
layoutDecorated(child, mChildFrame.left, mChildFrame.top, mChildFrame.right,
mChildFrame.bottom);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
if (!lp.isItemRemoved()) {
pushChildFrame(entry, mChildFrame, mTempLaneInfo.startLane,
getLaneSpanForChild(child), direction);
}
}
示例9: addHeaderView
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
/**
* @param header
* @param index
* @param orientation
*/
public int addHeaderView(View header, int index, int orientation) {
if (mHeaderLayout == null) {
mHeaderLayout = new LinearLayout(header.getContext());
if (orientation == LinearLayout.VERTICAL) {
mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
mHeaderLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
} else {
mHeaderLayout.setOrientation(LinearLayout.HORIZONTAL);
mHeaderLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
}
}
final int childCount = mHeaderLayout.getChildCount();
if (index < 0 || index > childCount) {
index = childCount;
}
mHeaderLayout.addView(header, index);
if (mHeaderLayout.getChildCount() == 1) {
int position = getHeaderViewPosition();
if (position != -1) {
notifyItemInserted(position);
}
}
return index;
}
示例10: addFooterView
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
/**
* Add footer view to mFooterLayout and set footer view position in mFooterLayout.
* When index = -1 or index >= child count in mFooterLayout,
* the effect of this method is the same as that of {@link #addFooterView(View)}.
*
* @param footer
* @param index the position in mFooterLayout of this footer.
* When index = -1 or index >= child count in mFooterLayout,
* the effect of this method is the same as that of {@link #addFooterView(View)}.
*/
public int addFooterView(View footer, int index, int orientation) {
if (mFooterLayout == null) {
mFooterLayout = new LinearLayout(footer.getContext());
if (orientation == LinearLayout.VERTICAL) {
mFooterLayout.setOrientation(LinearLayout.VERTICAL);
mFooterLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
} else {
mFooterLayout.setOrientation(LinearLayout.HORIZONTAL);
mFooterLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
}
}
final int childCount = mFooterLayout.getChildCount();
if (index < 0 || index > childCount) {
index = childCount;
}
mFooterLayout.addView(footer, index);
if (mFooterLayout.getChildCount() == 1) {
int position = getFooterViewPosition();
if (position != -1) {
notifyItemInserted(position);
}
}
return index;
}
示例11: setEmptyView
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
public void setEmptyView(View emptyView) {
boolean insert = false;
if (mEmptyLayout == null) {
mEmptyLayout = new FrameLayout(emptyView.getContext());
final LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
final ViewGroup.LayoutParams lp = emptyView.getLayoutParams();
if (lp != null) {
layoutParams.width = lp.width;
layoutParams.height = lp.height;
}
mEmptyLayout.setLayoutParams(layoutParams);
insert = true;
}
mEmptyLayout.removeAllViews();
mEmptyLayout.addView(emptyView);
mIsUseEmpty = true;
if (insert) {
if (getEmptyViewCount() == 1) {
int position = 0;
if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) {
position++;
}
notifyItemInserted(position);
}
}
}
示例12: addHeaderView
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
/**
* @param header
* @param index
* @param orientation
*/
public void addHeaderView(View header, int index, int orientation) {
if (mHeaderLayout == null) {
if (mCopyHeaderLayout == null) {
mHeaderLayout = new LinearLayout(header.getContext());
if (orientation == LinearLayout.VERTICAL) {
mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
mHeaderLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
} else {
mHeaderLayout.setOrientation(LinearLayout.HORIZONTAL);
mHeaderLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
}
mCopyHeaderLayout = mHeaderLayout;
} else {
mHeaderLayout = mCopyHeaderLayout;
}
}
index = index >= mHeaderLayout.getChildCount() ? -1 : index;
mHeaderLayout.addView(header, index);
this.notifyDataSetChanged();
}
示例13: addFooterView
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
/**
* Add footer view to mFooterLayout and set footer view position in mFooterLayout.
* When index = -1 or index >= child count in mFooterLayout,
* the effect of this method is the same as that of {@link #addFooterView(View)}.
*
* @param footer
* @param index the position in mFooterLayout of this footer.
* When index = -1 or index >= child count in mFooterLayout,
* the effect of this method is the same as that of {@link #addFooterView(View)}.
*/
public void addFooterView(View footer, int index) {
mNextLoadEnable = false;
if (mFooterLayout == null) {
if (mCopyFooterLayout == null) {
mFooterLayout = new LinearLayout(footer.getContext());
mFooterLayout.setOrientation(LinearLayout.VERTICAL);
mFooterLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
mCopyFooterLayout = mFooterLayout;
} else {
mFooterLayout = mCopyFooterLayout;
}
}
index = index >= mFooterLayout.getChildCount() ? -1 : index;
mFooterLayout.addView(footer, index);
this.notifyItemChanged(getItemCount());
}
示例14: addHeaderView
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
/**
* @param header
* @param index
* @param orientation
*/
public void addHeaderView(View header, int index, int orientation) {
if (mHeaderLayout == null) {
mHeaderLayout = new LinearLayout(header.getContext());
if (orientation == LinearLayout.VERTICAL) {
mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
mHeaderLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
} else {
mHeaderLayout.setOrientation(LinearLayout.HORIZONTAL);
mHeaderLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
}
}
index = index >= mHeaderLayout.getChildCount() ? -1 : index;
mHeaderLayout.addView(header, index);
if (mHeaderLayout.getChildCount() == 1) {
int position = getHeaderViewPosition();
if (position != -1) {
notifyItemInserted(position);
}
}
}
示例15: addFooterView
import android.support.v7.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
/**
* Add footer view to mFooterLayout and set footer view position in mFooterLayout.
* When index = -1 or index >= child count in mFooterLayout,
* the effect of this method is the same as that of {@link #addFooterView(View)}.
*
* @param footer
* @param index the position in mFooterLayout of this footer.
* When index = -1 or index >= child count in mFooterLayout,
* the effect of this method is the same as that of {@link #addFooterView(View)}.
*/
public void addFooterView(View footer, int index) {
if (mFooterLayout == null) {
mFooterLayout = new LinearLayout(footer.getContext());
mFooterLayout.setOrientation(LinearLayout.VERTICAL);
mFooterLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
}
index = index >= mFooterLayout.getChildCount() ? -1 : index;
mFooterLayout.addView(footer, index);
if (mFooterLayout.getChildCount() == 1) {
int position = getFooterViewPosition();
if (position != -1) {
notifyItemInserted(position);
}
}
}