本文整理了Java中android.widget.ImageView.getScaleX()
方法的一些代码示例,展示了ImageView.getScaleX()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.getScaleX()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:getScaleX
暂无
代码示例来源:origin: stackoverflow.com
final ImageView iv = (ImageView) findViewById(R.id.imageView);
ViewTreeObserver vto = iv.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// Start at 60
Log.d("test", "Before"+String.valueOf(iv.getWidth()* iv.getScaleX()));
iv.setScaleX((float) .5);
// Still at 60 after scale
Log.d("test", "After"+String.valueOf(iv.getWidth()* iv.getScaleX()));
}
});
代码示例来源:origin: prolificinteractive/Chandelier
private void setSelectedIndex(final int newSelectedIndex) {
// Un-select previous index
imageViews.get(selectedIndex).setSelected(false);
selectedIndex = newSelectedIndex;
isAnimating = true;
final int iW = measuredWidth / ornaments.size();
final int target = iW * selectedIndex + (iW - selectedSize) / 2;
final float currentScale = selectedImageView.getScaleX();
final float currentTranslation = selectedImageView.getTranslationX();
final Animation animation = new Animation() {
@Override protected void applyTransformation(float t, Transformation transformation) {
ViewCompat.setScaleX(selectedImageView, (DEFAULT_SCALE - currentScale) * t + currentScale);
ViewCompat.setTranslationX(selectedImageView,
(target - currentTranslation) * t + currentTranslation);
}
};
animation.setAnimationListener(animationListener);
animation.setDuration(shortAnimDuration);
animation.setInterpolator(ACCELERATE_DECELERATE_INTERPOLATOR);
selectedImageView.clearAnimation();
selectedImageView.startAnimation(animation);
}
代码示例来源:origin: stackoverflow.com
public Bitmap mergeBitmaps() {
Bitmap baseBitmap = ((BitmapDrawable) image.getDrawable()).getBitmap();
Bitmap mergedBitmap = Bitmap.createBitmap(baseBitmap.getWidth(), baseBitmap.getHeight(), baseBitmap.getConfig());
Canvas canvas = new Canvas(mergedBitmap);
canvas.drawBitmap(baseBitmap, new Matrix(), null);
for (ImageView sticker: stickers) {
float viewSizeRatio = (float) sticker.getWidth() / image.getWidth();
float bitmapSizeRatio = (float) sticker.getDrawable().getBounds().width() / image.getDrawable().getBounds().width();
float ratioFactor = viewSizeRatio / bitmapSizeRatio;
float deltaX = sticker.getTranslationX()* ratioFactor;
float deltaY = sticker.getTranslationY()* ratioFactor;
float scaleX = sticker.getScaleX()* ratioFactor;
float scaleY = sticker.getScaleY()* ratioFactor;
float rotation = sticker.getRotation();
Matrix matrix = new Matrix();
matrix.postScale(scaleX, scaleY);
matrix.postRotate(rotation);
matrix.postTranslate(deltaX, deltaY);
Bitmap stickerBitmap = ((BitmapDrawable) sticker.getDrawable()).getBitmap();
canvas.drawBitmap(stickerBitmap, matrix, null);
}
return mergedBitmap;
}
代码示例来源:origin: stackoverflow.com
double zoomFactor = zoomOut ? -0.2 : 0.2;
imageView.setScaleX(imageView.getScaleX() + zoomFactor);
imageView.setScaleY(imageView.getScaleY() + zoomFactor);
代码示例来源:origin: stackoverflow.com
public void onClick(View v) {
float x = img.getScaleX();
float y =img.getScaleY();
img.setScaleX((float) (x+1));
public void onClick(View v) {
float x = img.getScaleX();
float y =img.getScaleY();
img.setScaleX((float) (x-1));
代码示例来源:origin: stackoverflow.com
private ScrollPane addMapScroll() {
ScrollPane mapScroll = new ScrollPane();
ImageView mapViewO = addMapView();
mapScroll.setContent(new Group(mapViewO));
mapScroll.setPannable(true);
mapScroll.setVbarPolicy(ScrollBarPolicy.NEVER);
mapScroll.setHbarPolicy(ScrollBarPolicy.NEVER);
mapScroll.addEventFilter(ScrollEvent.ANY, e -> {
e.consume();
if (e.getDeltaY() == 0) {
return;
}
double scaleFactor
= (e.getDeltaY() > 0)
? SCALE_DELTA
: 1 / SCALE_DELTA;
if (scaleFactor * SCALE_TOTAL >= 1) {
mapViewO.setScaleX(mapViewO.getScaleX() * scaleFactor);
mapViewO.setScaleY(mapViewO.getScaleY() * scaleFactor);
SCALE_TOTAL *= scaleFactor;
}
});
return mapScroll;
}
内容来源于网络,如有侵权,请联系作者删除!