本文整理汇总了Java中android.view.View.isLayoutRequested方法的典型用法代码示例。如果您正苦于以下问题:Java View.isLayoutRequested方法的具体用法?Java View.isLayoutRequested怎么用?Java View.isLayoutRequested使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.isLayoutRequested方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildRect
import android.view.View; //导入方法依赖的package包/类
/**
* Get the position rect for the given child. If the child has currently requested layout
* or has a visibility of GONE.
*
* @param child child view to check
* @param transform true to include transformation in the output rect, false to
* only account for the base position
* @param out rect to set to the output values
*/
void getChildRect(View child, boolean transform, Rect out) {
if (child.isLayoutRequested() || child.getVisibility() == View.GONE) {
out.setEmpty();
return;
}
if (transform) {
getDescendantRect(child, out);
} else {
out.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
}
}
示例2: processLayoutRequest
import android.view.View; //导入方法依赖的package包/类
private void processLayoutRequest() {
mIsLayoutRequested = false;
for (int i = 0, childCount = getChildCount(); i != childCount; ++i) {
View child = getChildAt(i);
if (!child.isLayoutRequested()) {
continue;
}
child.measure(
MeasureSpec.makeMeasureSpec(child.getWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(child.getHeight(), MeasureSpec.EXACTLY));
child.layout(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
}
}
示例3: ensurePinnedHeaderLayout
import android.view.View; //导入方法依赖的package包/类
private void ensurePinnedHeaderLayout(View header, boolean forceLayout) {
if (header.isLayoutRequested() || forceLayout) {
int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY);
int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
try {
header.measure(widthSpec, heightSpec);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight());
}
}
示例4: measureScrollBar
import android.view.View; //导入方法依赖的package包/类
private int measureScrollBar(int position, float selectPercent, boolean needChange) {
if (scrollBar == null)
return 0;
View view = scrollBar.getSlideView();
if (view.isLayoutRequested() || needChange) {
View selectV = linearLayoutManager.findViewByPosition(position);
View unSelectV = linearLayoutManager.findViewByPosition(position + 1);
if (selectV != null) {
int tabWidth = (int) (selectV.getWidth() * (1 - selectPercent) + (unSelectV == null ? 0 : unSelectV.getWidth() * selectPercent));
int width = scrollBar.getWidth(tabWidth);
int height = scrollBar.getHeight(getHeight());
view.measure(width, height);
view.layout(0, 0, width, height);
return tabWidth;
}
}
return scrollBar.getSlideView().getWidth();
}
示例5: measureScrollBar
import android.view.View; //导入方法依赖的package包/类
private int measureScrollBar(int position, float selectPercent, boolean needChange) {
if (scrollBar == null)
return 0;
View view = scrollBar.getSlideView();
if (view.isLayoutRequested() || needChange) {
View selectV = getItemOutView(position);
View unSelectV;
if (position + 1 < mAdapter.getCount()) {
unSelectV = getItemOutView(position + 1);
} else {
unSelectV = getItemOutView(0);
}
if (selectV != null) {
int tabWidth = (int) (selectV.getWidth() * (1 - selectPercent) + (unSelectV == null ? 0 : unSelectV.getWidth() * selectPercent));
int width = scrollBar.getWidth(tabWidth);
int height = scrollBar.getHeight(getHeight());
view.measure(width, height);
view.layout(0, 0, width, height);
return tabWidth;
}
}
return scrollBar.getSlideView().getWidth();
}
示例6: onMeasure
import android.view.View; //导入方法依赖的package包/类
/**
*
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = MeasureSpec.getSize(heightMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
final View child = getChildAt(0);
if (child == null) {
setMeasuredDimension(0, width);
return;
}
if (child.isLayoutRequested()) {
// Always let child be as tall as it wants.
measureChild(child, widthMeasureSpec,
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
}
if (heightMode == MeasureSpec.UNSPECIFIED) {
ViewGroup.LayoutParams lp = getLayoutParams();
if (lp.height > 0) {
height = lp.height;
} else {
height = child.getMeasuredHeight();
}
}
setMeasuredDimension(width, height);
}
示例7: onMeasure
import android.view.View; //导入方法依赖的package包/类
/**
*
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = MeasureSpec.getSize(heightMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
final View child = getChildAt(0);
if (child == null) {
setMeasuredDimension(0, width);
return;
}
if (child.isLayoutRequested()) {
// Always let child be as tall as it wants.
measureChild(child, widthMeasureSpec,
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
}
if (heightMode == MeasureSpec.UNSPECIFIED) {
LayoutParams lp = getLayoutParams();
if (lp.height > 0) {
height = lp.height;
} else {
height = child.getMeasuredHeight();
}
}
setMeasuredDimension(width, height);
}
示例8: setupChild
import android.view.View; //导入方法依赖的package包/类
@TargetApi(11)
private void setupChild(View child, int position, int x, boolean flowDown, int childrenTop, boolean selected, boolean recycled) {
boolean isSelected = selected && shouldShowSelector();
boolean updateChildSelected = isSelected != child.isSelected();
int mode = this.mTouchMode;
boolean isPressed = mode > 0 && mode < 3 && this.mMotionPosition == position;
boolean updateChildPressed = isPressed != child.isPressed();
boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
LayoutParams p = (LayoutParams) child.getLayoutParams();
if (p == null) {
p = (LayoutParams) generateDefaultLayoutParams();
}
p.viewType = this.mAdapter.getItemViewType(position);
if ((!recycled || p.forceAdd) && !(p.recycledHeaderFooter && p.viewType == -2)) {
p.forceAdd = false;
if (p.viewType == -2) {
p.recycledHeaderFooter = true;
}
addViewInLayout(child, flowDown ? -1 : 0, p, true);
} else {
attachViewToParent(child, flowDown ? -1 : 0, p);
}
if (updateChildSelected) {
child.setSelected(isSelected);
}
if (updateChildPressed) {
child.setPressed(isPressed);
}
if (!(this.mChoiceMode == 0 || this.mCheckStates == null)) {
if (child instanceof Checkable) {
((Checkable) child).setChecked(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
} else if (VERSION.SDK_INT >= 11) {
child.setActivated(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
}
}
if (needToMeasure) {
int childWidthSpec;
int childHeightSpec = ViewGroup.getChildMeasureSpec(this.mHeightMeasureSpec, this.mListPadding.top + this.mListPadding.bottom, p.height);
int lpWidth = p.width;
if (lpWidth > 0) {
childWidthSpec = MeasureSpec.makeMeasureSpec(lpWidth, 1073741824);
} else {
childWidthSpec = MeasureSpec.makeMeasureSpec(0, 0);
}
child.measure(childWidthSpec, childHeightSpec);
} else {
cleanupLayoutState(child);
}
int w = child.getMeasuredWidth();
int h = child.getMeasuredHeight();
int childLeft = flowDown ? x : x - w;
if (needToMeasure) {
child.layout(childLeft, childrenTop, childLeft + w, childrenTop + h);
} else {
child.offsetLeftAndRight(childLeft - child.getLeft());
child.offsetTopAndBottom(childrenTop - child.getTop());
}
if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
child.setDrawingCacheEnabled(true);
}
if (VERSION.SDK_INT >= 11 && recycled && ((LayoutParams) child.getLayoutParams()).scrappedFromPosition != position) {
child.jumpDrawablesToCurrentState();
}
}
示例9: ensurePinnedHeaderLayout
import android.view.View; //导入方法依赖的package包/类
private void ensurePinnedHeaderLayout(View header, boolean forceLayout) {
if (header.isLayoutRequested() || forceLayout) {
ViewGroup.LayoutParams layoutParams = header.getLayoutParams();
int heightSpec = MeasureSpec.makeMeasureSpec(layoutParams.height, MeasureSpec.EXACTLY);
int widthSpec = MeasureSpec.makeMeasureSpec(layoutParams.width, MeasureSpec.EXACTLY);
try {
header.measure(widthSpec, heightSpec);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight());
}
}
示例10: setupChild
import android.view.View; //导入方法依赖的package包/类
private void setupChild(View child, int position, int y, boolean flowDown, int childrenLeft,
boolean selected, boolean recycled) {
boolean isSelected = selected && shouldShowSelector();
boolean updateChildSelected = isSelected != child.isSelected();
int mode = this.mTouchMode;
boolean isPressed = mode > 0 && mode < 3 && this.mMotionPosition == position;
boolean updateChildPressed = isPressed != child.isPressed();
boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
ViewGroup.LayoutParams p = (LayoutParams) child.getLayoutParams();
if (p == null) {
ViewGroup.LayoutParams layoutParams = new LayoutParams(-1, -2, 0);
}
p.viewType = this.mAdapter.getItemViewType(position);
p.scrappedFromPosition = position;
if ((!recycled || p.forceAdd) && !(p.recycledHeaderFooter && p.viewType == -2)) {
p.forceAdd = false;
if (p.viewType == -2) {
p.recycledHeaderFooter = true;
}
addViewInLayout(child, flowDown ? -1 : 0, p, true);
} else {
attachViewToParent(child, flowDown ? -1 : 0, p);
}
if (updateChildSelected) {
child.setSelected(isSelected);
}
if (updateChildPressed) {
child.setPressed(isPressed);
}
if (needToMeasure) {
int childHeightSpec;
int childWidthSpec = ViewGroup.getChildMeasureSpec(this.mWidthMeasureSpec, this
.mListPadding.left + this.mListPadding.right, p.width);
int lpHeight = p.height;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, 1073741824);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0, 0);
}
onMeasureChild(child, position, childWidthSpec, childHeightSpec);
} else {
cleanupLayoutState(child);
}
int w = child.getMeasuredWidth();
int h = child.getMeasuredHeight();
int childTop = flowDown ? y : y - h;
if (needToMeasure) {
onLayoutChild(child, position, childrenLeft, childTop, childrenLeft + w, childTop + h);
} else {
onOffsetChild(child, position, childrenLeft - child.getLeft(), childTop - child
.getTop());
}
if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
child.setDrawingCacheEnabled(true);
}
}
示例11: ensurePinnedHeaderLayout
import android.view.View; //导入方法依赖的package包/类
private void ensurePinnedHeaderLayout(View header) {
if (header.isLayoutRequested()) {
int heightSpec;
int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), this.mWidthMode);
LayoutParams layoutParams = header.getLayoutParams();
if (layoutParams == null || layoutParams.height <= 0) {
heightSpec = MeasureSpec.makeMeasureSpec(0, 0);
} else {
heightSpec = MeasureSpec.makeMeasureSpec(layoutParams.height, 1073741824);
}
header.measure(widthSpec, heightSpec);
header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight());
}
}
示例12: getChildRect
import android.view.View; //导入方法依赖的package包/类
void getChildRect(View child, boolean transform, Rect out) {
if (child.isLayoutRequested() || child.getVisibility() == 8) {
out.set(0, 0, 0, 0);
} else if (transform) {
getDescendantRect(child, out);
} else {
out.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
}
}
示例13: prepareContent
import android.view.View; //导入方法依赖的package包/类
private void prepareContent() {
if (mAnimating) {
return;
}
// Something changed in the content, we need to honor the layout request
// before creating the cached bitmap
final View content = mContent;
if (content.isLayoutRequested()) {
if (mVertical) {
final int handleHeight = mHandleHeight;
int height = getBottom() - getTop() - handleHeight - mTopOffset;
content.measure(MeasureSpec.makeMeasureSpec(getRight()
- getLeft(), MeasureSpec.EXACTLY), MeasureSpec
.makeMeasureSpec(height, MeasureSpec.AT_MOST));
if (mInvert)
content.layout(0, mTopOffset, content.getMeasuredWidth(),
mTopOffset + content.getMeasuredHeight());
else
content.layout(
0,
mTopOffset + handleHeight,
content.getMeasuredWidth(),
mTopOffset + handleHeight
+ content.getMeasuredHeight());
} else {
final int handleWidth = mHandle.getWidth();
int width = getRight() - getLeft() - handleWidth - mTopOffset;
content.measure(MeasureSpec.makeMeasureSpec(width,
MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(
getBottom() - getTop(), MeasureSpec.EXACTLY));
if (mInvert)
content.layout(mTopOffset, 0,
mTopOffset + content.getMeasuredWidth(),
content.getMeasuredHeight());
else
content.layout(handleWidth + mTopOffset, 0, mTopOffset
+ handleWidth + content.getMeasuredWidth(),
content.getMeasuredHeight());
}
}
// Try only once... we should really loop but it's not a big deal
// if the draw was cancelled, it will only be temporary anyway
content.getViewTreeObserver().dispatchOnPreDraw();
content.buildDrawingCache();
content.setVisibility(View.GONE);
}
示例14: makeAndAddView
import android.view.View; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void makeAndAddView(View child, int index) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) child.getLayoutParams();
addViewInLayout(child, 0, lp, true);
final boolean needToMeasure = child.isLayoutRequested();
if (needToMeasure) {
int childWidthSpec = getChildMeasureSpec(getWidthMeasureSpec(),
getPaddingLeft() + getPaddingRight() + lp.leftMargin + lp.rightMargin,
lp.width);
int childHeightSpec = getChildMeasureSpec(getHeightMeasureSpec(),
getPaddingTop() + getPaddingBottom() + lp.topMargin + lp.bottomMargin,
lp.height);
child.measure(childWidthSpec, childHeightSpec);
} else {
cleanupLayoutState(child);
}
int w = child.getMeasuredWidth();
int h = child.getMeasuredHeight();
int gravity = lp.gravity;
if (gravity == -1) {
gravity = Gravity.TOP | Gravity.START;
}
int layoutDirection = 0;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN)
layoutDirection = getLayoutDirection();
final int absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection);
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
int childLeft;
int childTop;
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.CENTER_HORIZONTAL:
childLeft = (getWidth() + getPaddingLeft() - getPaddingRight() - w) / 2 +
lp.leftMargin - lp.rightMargin;
break;
case Gravity.END:
childLeft = getWidth() + getPaddingRight() - w - lp.rightMargin;
break;
case Gravity.START:
default:
childLeft = getPaddingLeft() + lp.leftMargin;
break;
}
switch (verticalGravity) {
case Gravity.CENTER_VERTICAL:
childTop = (getHeight() + getPaddingTop() - getPaddingBottom() - h) / 2 +
lp.topMargin - lp.bottomMargin;
break;
case Gravity.BOTTOM:
childTop = getHeight() - getPaddingBottom() - h - lp.bottomMargin;
break;
case Gravity.TOP:
default:
childTop = getPaddingTop() + lp.topMargin;
break;
}
child.layout(childLeft, childTop, childLeft + w, childTop + h);
// 缩放层叠效果
adjustChildView(child, index);
}
示例15: shouldMeasureChild
import android.view.View; //导入方法依赖的package包/类
/**
* RecyclerView internally does its own View measurement caching which should help with
* WRAP_CONTENT.
* <p>
* Use this method if the View is not yet measured and you need to decide whether to
* measure this View or not.
*/
boolean shouldMeasureChild(View child, int widthSpec, int heightSpec, LayoutParams lp) {
return child.isLayoutRequested()
|| !mMeasurementCacheEnabled
|| !isMeasurementUpToDate(child.getWidth(), widthSpec, lp.width)
|| !isMeasurementUpToDate(child.getHeight(), heightSpec, lp.height);
}