本文整理匯總了Java中android.view.View.MeasureSpec.getSize方法的典型用法代碼示例。如果您正苦於以下問題:Java MeasureSpec.getSize方法的具體用法?Java MeasureSpec.getSize怎麽用?Java MeasureSpec.getSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.View.MeasureSpec
的用法示例。
在下文中一共展示了MeasureSpec.getSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMeasure
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
protected void onMeasure(int i, int i2) {
int size = MeasureSpec.getSize(i2);
Activity activity = (Activity) getContext();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(this.b);
int height = (activity.getWindowManager().getDefaultDisplay().getHeight() - this.b.top) -
size;
if (!(this.d == null || size == 0)) {
if (height > 100) {
this.d.onKeyboardShown((Math.abs(this.b.height()) - getPaddingBottom()) -
getPaddingTop());
} else {
this.d.onKeyboardHidden();
}
}
super.onMeasure(i, i2);
}
示例2: onMeasure
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
boolean lockedExpanded = widthMode == 1073741824;
setFillViewport(lockedExpanded);
int childCount = this.mTabLayout.getChildCount();
if (childCount <= 1 || !(widthMode == 1073741824 || widthMode == Integer.MIN_VALUE)) {
this.mMaxTabWidth = -1;
} else if (childCount > 2) {
this.mMaxTabWidth = (int) (((float) MeasureSpec.getSize(widthMeasureSpec)) * 0.4f);
} else {
this.mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
}
int oldWidth = getMeasuredWidth();
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int newWidth = getMeasuredWidth();
if (lockedExpanded && oldWidth != newWidth) {
setCurrentItem(this.mSelectedTabIndex);
}
}
示例3: onMeasure
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
float height;
int measuredWidth = MeasureSpec.getSize(widthMeasureSpec);
if (MeasureSpec.getMode(heightMeasureSpec) == 1073741824) {
height = (float) MeasureSpec.getSize(heightMeasureSpec);
} else {
this.mBounds.setEmpty();
this.mBounds.bottom = (int) (this.mPaintText.descent() - this.mPaintText.ascent());
height = ((((float) (this.mBounds.bottom - this.mBounds.top)) + this
.mFooterLineHeight) + this.mFooterPadding) + this.mTopPadding;
if (this.mFooterIndicatorStyle != IndicatorStyle.None) {
height += this.mFooterIndicatorHeight;
}
}
setMeasuredDimension(measuredWidth, (int) height);
}
示例4: onMeasure
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (MeasureSpec.getMode(widthMeasureSpec) != 1073741824) {
throw new IllegalStateException("Must measure with an exact width");
}
int height;
int heightPadding = getPaddingTop() + getPaddingBottom();
int childHeightSpec = getChildMeasureSpec(heightMeasureSpec, heightPadding, -2);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int childWidthSpec = getChildMeasureSpec(widthMeasureSpec, (int) (((float) widthSize) * 0.2f), -2);
this.mPrevText.measure(childWidthSpec, childHeightSpec);
this.mCurrText.measure(childWidthSpec, childHeightSpec);
this.mNextText.measure(childWidthSpec, childHeightSpec);
if (MeasureSpec.getMode(heightMeasureSpec) == 1073741824) {
height = MeasureSpec.getSize(heightMeasureSpec);
} else {
height = Math.max(getMinHeight(), this.mCurrText.getMeasuredHeight() + heightPadding);
}
setMeasuredDimension(widthSize, ViewCompat.resolveSizeAndState(height, heightMeasureSpec, ViewCompat.getMeasuredState(this.mCurrText) << 16));
}
示例5: isMeasurementUpToDate
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
private static boolean isMeasurementUpToDate(int childSize, int spec, int dimension) {
int specMode = MeasureSpec.getMode(spec);
int specSize = MeasureSpec.getSize(spec);
if (dimension > 0 && childSize != dimension) {
return false;
}
switch (specMode) {
case Integer.MIN_VALUE:
if (specSize < childSize) {
return false;
}
return true;
case 0:
return true;
case 1073741824:
if (specSize != childSize) {
return false;
}
return true;
default:
return false;
}
}
示例6: onMeasure
import android.view.View.MeasureSpec; //導入方法依賴的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.MeasureSpec; //導入方法依賴的package包/類
protected void onMeasure(int i, int i2) {
super.onMeasure(i, i2);
int size = MeasureSpec.getSize(i);
int size2 = MeasureSpec.getSize(i2);
Log.d("onMeasure", "ActionBoard, width = " + size + ", height = " + size2);
LayoutParams layoutParams = this.c.getLayoutParams();
layoutParams.height = this.c.e(size);
layoutParams.width = size;
LayoutParams layoutParams2 = this.e.getLayoutParams();
layoutParams2.height = size2 - layoutParams.height;
layoutParams2.width = size;
}
示例8: createPinnedShadow
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
private void createPinnedShadow(int position) {
int heightMode;
int heightSize;
PinnedViewShadow pinnedShadow = this.mRecycleShadow;
View recycleView = pinnedShadow == null ? null : pinnedShadow.view;
this.mRecycleShadow = null;
View pinnedView = getAdapter().getView(position, recycleView, this);
LayoutParams layoutParams = (LayoutParams) pinnedView.getLayoutParams();
if (layoutParams == null) {
heightMode = Integer.MIN_VALUE;
heightSize = getHeight();
} else {
heightMode = MeasureSpec.getMode(layoutParams.height);
heightSize = MeasureSpec.getSize(layoutParams.height);
}
if (heightMode == 0) {
heightMode = 1073741824;
}
int maxHeight = (getHeight() - getListPaddingTop()) - getListPaddingBottom();
if (heightSize > maxHeight) {
heightSize = maxHeight;
}
pinnedView.measure(MeasureSpec.makeMeasureSpec((getWidth() - getListPaddingLeft()) -
getListPaddingRight(), 1073741824), MeasureSpec.makeMeasureSpec(heightSize,
heightMode));
pinnedView.layout(0, 0, pinnedView.getMeasuredWidth(), pinnedView.getMeasuredHeight());
this.mTranslateY = 0;
if (pinnedShadow == null) {
pinnedShadow = new PinnedViewShadow();
}
pinnedShadow.position = position;
pinnedShadow.view = pinnedView;
this.mPinnedShadow = pinnedShadow;
}
示例9: onMeasure
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if (MeasureSpec.getMode(widthMeasureSpec) == Integer.MIN_VALUE && MeasureSpec.getMode
(heightMeasureSpec) == Integer.MIN_VALUE) {
MarginLayoutParams params = (MarginLayoutParams) getLayoutParams();
height = Math.min((dip(40) - params.leftMargin) - params.rightMargin, (dip(40) -
params.bottomMargin) - params.topMargin);
width = height;
}
int size = Math.min((width - getPaddingLeft()) - getPaddingRight(), (height -
getPaddingBottom()) - getPaddingTop());
setMeasuredDimension(size, size);
}
示例10: resolveAdjustedSize
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
public int resolveAdjustedSize(int desiredSize, int measureSpec) {
int result = desiredSize;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
switch (specMode) {
case Integer.MIN_VALUE:
return Math.min(desiredSize, specSize);
case 0:
return desiredSize;
case 1073741824:
return specSize;
default:
return result;
}
}
示例11: onMeasure
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
boolean z;
boolean wasFormatted = this.mFormatItems;
if (MeasureSpec.getMode(widthMeasureSpec) == 1073741824) {
z = true;
} else {
z = false;
}
this.mFormatItems = z;
if (wasFormatted != this.mFormatItems) {
this.mFormatItemsWidth = 0;
}
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
if (!(!this.mFormatItems || this.mMenu == null || widthSize == this.mFormatItemsWidth)) {
this.mFormatItemsWidth = widthSize;
this.mMenu.onItemsChanged(true);
}
int childCount = getChildCount();
if (!this.mFormatItems || childCount <= 0) {
for (int i = 0; i < childCount; i++) {
LayoutParams lp = (LayoutParams) getChildAt(i).getLayoutParams();
lp.rightMargin = 0;
lp.leftMargin = 0;
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
onMeasureExactFormat(widthMeasureSpec, heightMeasureSpec);
}
示例12: getDefaultSize2
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
private static int getDefaultSize2(int size, int measureSpec) {
int result = size;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
switch (specMode) {
case Integer.MIN_VALUE:
return Math.min(size, specSize);
case 0:
return size;
case 1073741824:
return specSize;
default:
return result;
}
}
示例13: onMeasure
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
protected void onMeasure(int i, int i2) {
int size = MeasureSpec.getSize(i2);
Activity activity = (Activity) getContext();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(this.b);
int height = (activity.getWindowManager().getDefaultDisplay().getHeight() - this.b.top) - size;
if (!(this.d == null || size == 0)) {
if (height > 100) {
this.d.onKeyboardShown((Math.abs(this.b.height()) - getPaddingBottom()) - getPaddingTop());
} else {
this.d.onKeyboardHidden();
}
}
super.onMeasure(i, i2);
}
示例14: chooseSize
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
public static int chooseSize(int spec, int desired, int min) {
int mode = MeasureSpec.getMode(spec);
int size = MeasureSpec.getSize(spec);
switch (mode) {
case Integer.MIN_VALUE:
return Math.min(size, Math.max(desired, min));
case 1073741824:
return size;
default:
return Math.max(desired, min);
}
}
示例15: onMeasure
import android.view.View.MeasureSpec; //導入方法依賴的package包/類
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);
int modeWidth = MeasureSpec.getMode(widthMeasureSpec);
int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);
int modeHeight = MeasureSpec.getMode(heightMeasureSpec);
int width = 0;
int height = 0;
int lineWidth = 0;
int lineHeight = 0;
int cCount = getChildCount();
for (int i = 0; i < cCount; i++) {
View child = getChildAt(i);
if (child.getVisibility() != 8) {
measureChild(child, widthMeasureSpec, heightMeasureSpec);
MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
int childWidth = (child.getMeasuredWidth() + lp.leftMargin) + lp.rightMargin;
int childHeight = (child.getMeasuredHeight() + lp.topMargin) + lp.bottomMargin;
if (lineWidth + childWidth > (sizeWidth - getPaddingLeft()) - getPaddingRight()) {
width = Math.max(width, lineWidth);
lineWidth = childWidth;
height += lineHeight;
lineHeight = childHeight;
} else {
lineWidth += childWidth;
lineHeight = Math.max(lineHeight, childHeight);
}
if (i == cCount - 1) {
width = Math.max(lineWidth, width);
height += lineHeight;
}
} else if (i == cCount - 1) {
width = Math.max(lineWidth, width);
height += lineHeight;
}
}
if (modeWidth != 1073741824) {
sizeWidth = (getPaddingLeft() + width) + getPaddingRight();
}
if (modeHeight != 1073741824) {
sizeHeight = (getPaddingTop() + height) + getPaddingBottom();
}
setMeasuredDimension(sizeWidth, sizeHeight);
}