当前位置: 首页>>代码示例>>Java>>正文


Java ScaleType.FIT_XY属性代码示例

本文整理汇总了Java中android.widget.ImageView.ScaleType.FIT_XY属性的典型用法代码示例。如果您正苦于以下问题:Java ScaleType.FIT_XY属性的具体用法?Java ScaleType.FIT_XY怎么用?Java ScaleType.FIT_XY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.widget.ImageView.ScaleType的用法示例。


在下文中一共展示了ScaleType.FIT_XY属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:21,代码来源:WXImage.java

示例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;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:19,代码来源:WXImage.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:SelectableRoundedImageView.java

示例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));
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:SelectableRoundedImageView.java

示例5: onResourceReady

@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
    if (bitmap != null && view.getScaleType() != ScaleType.FIT_XY) {
        view.setScaleType(ScaleType.FIT_XY);
    }
    super.onResourceReady(bitmap, anim);
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:7,代码来源:MyBitmapImageViewTarget.java

示例6: a

private static int a(int i, int i2, int i3, int i4, ScaleType scaleType) {
    if (i == 0 && i2 == 0) {
        return i3;
    }
    if (scaleType == ScaleType.FIT_XY) {
        if (i == 0) {
            return i3;
        }
        return i;
    } else if (i == 0) {
        return (int) ((((double) i2) / ((double) i4)) * ((double) i3));
    } else {
        if (i2 == 0) {
            return i;
        }
        double d = ((double) i4) / ((double) i3);
        if (scaleType == ScaleType.CENTER_CROP) {
            if (((double) i) * d < ((double) i2)) {
                return (int) (((double) i2) / d);
            }
            return i;
        } else if (((double) i) * d > ((double) i2)) {
            return (int) (((double) i2) / d);
        } else {
            return i;
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:n.java

示例7: getZoomedRect

public RectF getZoomedRect() {
    if (this.mScaleType == ScaleType.FIT_XY) {
        throw new UnsupportedOperationException("getZoomedRect() not supported with FIT_XY");
    }
    PointF topLeft = transformCoordTouchToBitmap(0.0f, 0.0f, true);
    PointF bottomRight = transformCoordTouchToBitmap((float) this.viewWidth, (float) this
            .viewHeight, true);
    float w = (float) getDrawable().getIntrinsicWidth();
    float h = (float) getDrawable().getIntrinsicHeight();
    return new RectF(topLeft.x / w, topLeft.y / h, bottomRight.x / w, bottomRight.y / h);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:TouchImageView.java

示例8: getResizedDimension

private static int getResizedDimension(int maxPrimary, int maxSecondary, int actualPrimary, int actualSecondary, ScaleType scaleType) {
    if (maxPrimary == 0 && maxSecondary == 0) {
        return actualPrimary;
    }
    if (scaleType == ScaleType.FIT_XY) {
        if (maxPrimary != 0) {
            return maxPrimary;
        }
        return actualPrimary;
    } else if (maxPrimary == 0) {
        return (int) (((double) actualPrimary) * (((double) maxSecondary) / ((double) actualSecondary)));
    } else if (maxSecondary == 0) {
        return maxPrimary;
    } else {
        double ratio = ((double) actualSecondary) / ((double) actualPrimary);
        int resized = maxPrimary;
        if (scaleType == ScaleType.CENTER_CROP) {
            if (((double) resized) * ratio < ((double) maxSecondary)) {
                resized = (int) (((double) maxSecondary) / ratio);
            }
            return resized;
        }
        if (((double) resized) * ratio > ((double) maxSecondary)) {
            resized = (int) (((double) maxSecondary) / ratio);
        }
        return resized;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:ImageRequest.java


注:本文中的android.widget.ImageView.ScaleType.FIT_XY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。