本文整理汇总了Java中android.widget.ImageView.ScaleType.FIT_CENTER属性的典型用法代码示例。如果您正苦于以下问题:Java ScaleType.FIT_CENTER属性的具体用法?Java ScaleType.FIT_CENTER怎么用?Java ScaleType.FIT_CENTER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.widget.ImageView.ScaleType
的用法示例。
在下文中一共展示了ScaleType.FIT_CENTER属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResizeMode
private ScaleType getResizeMode(String resizeMode) {
ScaleType scaleType = ScaleType.FIT_XY;
if (TextUtils.isEmpty(resizeMode)) {
return scaleType;
}
if (resizeMode.equals("cover")) {
scaleType = ScaleType.CENTER_CROP;
} else if (resizeMode.equals("contain")) {
scaleType = ScaleType.FIT_CENTER;
} else if (resizeMode.equals("stretch")) {
scaleType = ScaleType.FIT_XY;
} else if (resizeMode.equals("center")) {
scaleType = ScaleType.CENTER;
} else if (resizeMode.equals("start")) {
scaleType = ScaleType.MATRIX;
} else if (resizeMode.equals("end")) {
scaleType = ScaleType.FIT_END;
}
return scaleType;
}
示例2: getResizeMode
private ScaleType getResizeMode(String resizeMode) {
ScaleType scaleType = ScaleType.FIT_XY;
if (TextUtils.isEmpty(resizeMode)) {
return scaleType;
}
switch (resizeMode) {
case "cover":
scaleType = ScaleType.CENTER_CROP;
break;
case "contain":
scaleType = ScaleType.FIT_CENTER;
break;
case "stretch":
scaleType = ScaleType.FIT_XY;
break;
}
return scaleType;
}
示例3: configureBounds
private void configureBounds(Canvas canvas) {
Rect clipBounds = canvas.getClipBounds();
Matrix canvasMatrix = canvas.getMatrix();
if (ScaleType.CENTER == this.mScaleType) {
this.mBounds.set(clipBounds);
} else if (ScaleType.CENTER_CROP == this.mScaleType) {
applyScaleToRadii(canvasMatrix);
this.mBounds.set(clipBounds);
} else if (ScaleType.FIT_XY == this.mScaleType) {
Matrix m = new Matrix();
m.setRectToRect(this.mBitmapRect, new RectF(clipBounds), ScaleToFit.FILL);
this.mBitmapShader.setLocalMatrix(m);
this.mBounds.set(clipBounds);
} else if (ScaleType.FIT_START == this.mScaleType || ScaleType.FIT_END == this
.mScaleType || ScaleType.FIT_CENTER == this.mScaleType || ScaleType
.CENTER_INSIDE == this.mScaleType) {
applyScaleToRadii(canvasMatrix);
this.mBounds.set(this.mBitmapRect);
} else if (ScaleType.MATRIX == this.mScaleType) {
applyScaleToRadii(canvasMatrix);
this.mBounds.set(this.mBitmapRect);
}
}
示例4: adjustCanvasForBorder
private void adjustCanvasForBorder(Canvas canvas) {
float[] values = new float[9];
canvas.getMatrix().getValues(values);
float scaleFactorX = values[0];
float scaleFactorY = values[4];
float translateX = values[2];
float translateY = values[5];
float newScaleX = this.mBounds.width() / ((this.mBounds.width() + this.mBorderWidth)
+ this.mBorderWidth);
float newScaleY = this.mBounds.height() / ((this.mBounds.height() + this
.mBorderWidth) + this.mBorderWidth);
canvas.scale(newScaleX, newScaleY);
if (ScaleType.FIT_START == this.mScaleType || ScaleType.FIT_END == this.mScaleType ||
ScaleType.FIT_XY == this.mScaleType || ScaleType.FIT_CENTER == this
.mScaleType || ScaleType.CENTER_INSIDE == this.mScaleType || ScaleType.MATRIX
== this.mScaleType) {
canvas.translate(this.mBorderWidth, this.mBorderWidth);
} else if (ScaleType.CENTER == this.mScaleType || ScaleType.CENTER_CROP == this
.mScaleType) {
canvas.translate((-translateX) / (newScaleX * scaleFactorX), (-translateY) /
(newScaleY * scaleFactorY));
canvas.translate(-(this.mBounds.left - this.mBorderWidth), -(this.mBounds.top -
this.mBorderWidth));
}
}
示例5: sharedConstructing
private void sharedConstructing(Context context) {
super.setClickable(true);
this.context = context;
this.mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
this.mGestureDetector = new GestureDetector(context, new GestureListener());
this.matrix = new Matrix();
this.prevMatrix = new Matrix();
this.m = new float[9];
this.normalizedScale = 1.0f;
if (this.mScaleType == null) {
this.mScaleType = ScaleType.FIT_CENTER;
}
this.minScale = 1.0f;
this.maxScale = IPhotoView.DEFAULT_MAX_SCALE;
this.superMinScale = 0.75f * this.minScale;
this.superMaxScale = SUPER_MAX_MULTIPLIER * this.maxScale;
setImageMatrix(this.matrix);
setScaleType(ScaleType.MATRIX);
setState(State.NONE);
this.onDrawReady = false;
super.setOnTouchListener(new PrivateOnTouchListener());
}
示例6: setScaleType
public RoundedDrawable setScaleType(ScaleType scaleType) {
if (scaleType == null) {
scaleType = ScaleType.FIT_CENTER;
}
if (mScaleType != scaleType) {
mScaleType = scaleType;
updateShaderMatrix();
}
return this;
}
示例7: setScaleType
public RoundedDrawable setScaleType(ScaleType scaleType) {
if (scaleType == null) {
scaleType = ScaleType.FIT_CENTER;
}
if (mScaleType != scaleType) {
mScaleType = scaleType;
updateShaderMatrix();
}
return this;
}
示例8: setScaleType
public RoundedPagerDrawable setScaleType(ScaleType scaleType) {
if (scaleType == null) {
scaleType = ScaleType.FIT_CENTER;
}
if (this.mScaleType != scaleType) {
this.mScaleType = scaleType;
updateShaderMatrix();
}
return this;
}
示例9: RoundedImageView
public RoundedImageView(Context context) {
super(context);
this.mCornerRadii = new float[]{0.0f, 0.0f, 0.0f, 0.0f};
this.mBorderColor = ColorStateList.valueOf(-16777216);
this.mBorderWidth = 0.0f;
this.mColorFilter = null;
this.mColorMod = false;
this.mHasColorFilter = false;
this.mIsOval = false;
this.mMutateBackground = false;
this.mScaleType = ScaleType.FIT_CENTER;
this.mTileModeX = DEFAULT_TILE_MODE;
this.mTileModeY = DEFAULT_TILE_MODE;
}
示例10: setScaleType
public RoundedDrawable setScaleType(ScaleType scaleType) {
if (scaleType == null) {
scaleType = ScaleType.FIT_CENTER;
}
if (mScaleType != scaleType) {
mScaleType = scaleType;
updateShaderMatrix();
}
return this;
}
示例11: SelectableRoundedImageView
public SelectableRoundedImageView(Context context) {
super(context);
this.mResource = 0;
this.mScaleType = ScaleType.FIT_CENTER;
this.mLeftTopCornerRadius = 0.0f;
this.mRightTopCornerRadius = 0.0f;
this.mLeftBottomCornerRadius = 0.0f;
this.mRightBottomCornerRadius = 0.0f;
this.mBorderWidth = 0.0f;
this.mBorderColor = ColorStateList.valueOf(-16777216);
this.isOval = false;
this.mRadii = new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
}
示例12: setScaleType
public RoundedDrawable setScaleType(ScaleType scaleType) {
if (scaleType == null) {
scaleType = ScaleType.FIT_CENTER;
}
if (this.mScaleType != scaleType) {
this.mScaleType = scaleType;
updateShaderMatrix();
}
return this;
}
示例13: getIconScaleType
private static ScaleType getIconScaleType(int index, int keyId) {
if (mUseLargerIcons) {
return ScaleType.FIT_CENTER;
} else {
ScaleType origScaleType = mNavbarViewInfo[index] == null ? ScaleType.CENTER :
mNavbarViewInfo[index].originalScaleType.get(keyId, ScaleType.CENTER);
if (index == 0) {
return (mNavbarHeight < 75 ? ScaleType.CENTER_INSIDE : origScaleType);
} else {
boolean hasVerticalNavbar = mGbContext.getResources().getBoolean(R.bool.hasVerticalNavbar);
return (mNavbarWidth < 75 && hasVerticalNavbar ? ScaleType.CENTER_INSIDE :
origScaleType);
}
}
}
示例14: setScaleType
public RoundedDrawable setScaleType(ScaleType scaleType)
{
if (scaleType == null)
{
scaleType = ScaleType.FIT_CENTER;
}
if (mScaleType != scaleType)
{
mScaleType = scaleType;
updateShaderMatrix();
}
return this;
}