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


Java ImageView.getWidth方法代码示例

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


在下文中一共展示了ImageView.getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getImageWidth

import android.widget.ImageView; //导入方法依赖的package包/类
public static int getImageWidth(ImageView imageView){
    if (imageView != null){
        int width = 0;
        ViewGroup.LayoutParams params = imageView.getLayoutParams();
        if (params != null && params.width != ViewGroup.LayoutParams.WRAP_CONTENT){
            width = imageView.getWidth();
        }

        if (width <= 0 && params != null){
            width = params.width;
        }

        if (width <= 0 ){
            width = getImageViewFieldValue(imageView,"mMaxWidth");
        }
        return width;
    }
    return DEFAULT_WIDTH;

}
 
开发者ID:SingleShu,项目名称:ImageLoaderLibrary,代码行数:21,代码来源:ImageHelper.java

示例2: getDefaultWidth

import android.widget.ImageView; //导入方法依赖的package包/类
public int getDefaultWidth() {
    ImageView imageView = this.mViewRef.get();
    if (imageView != null) {
        ViewGroup.LayoutParams params = imageView.getLayoutParams();
        int width = 0;
        if (this.checkActualViewSize && params != null && params.width != -2) {
            width = imageView.getWidth();
        }
        if (width <= 0 && params != null) {
            width = params.width;
        }
        if (width <= 0) {
            width = getImageViewFieldValue(imageView, "mMaxWidth");
        }

        return width;
    } else {
        return 0;
    }
}
 
开发者ID:redleaf2002,项目名称:magic_imageloader_network,代码行数:21,代码来源:ImageViewAware.java

示例3: calculateIv

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * 计算点击的ImageView的大小
 *
 * @param iv 点击的ImageView
 */
private void calculateIv(ImageView iv) {
    if (null != iv) {
        // 如果传入ImageView,就按该ImageView计算
        mIvWidth = iv.getWidth();
        mIvHeight = iv.getHeight();

        int[] points = new int[2];
        iv.getLocationInWindow(points);
        mIvX = points[0];
        mIvY = points[1];
    } else {
        // 如果ImageView为空,就宽高设置为0
        mIvWidth = 0;
        mIvHeight = 0;
        // 并且把起点坐标设置0
        mIvX = 0;
        mIvY = 0;
    }
}
 
开发者ID:yhyzgn,项目名称:Widgets,代码行数:25,代码来源:ImgPreCfg.java

示例4: handleZoomOut

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Ação de ZoomOut - Diminuir imagem
 */
public static void handleZoomOut(ImageView mImageSelected) {
    if (mImageSelected.getWidth() < 50)
        return;

    ViewGroup.LayoutParams params = mImageSelected.getLayoutParams();
    params.width = (int) (mImageSelected.getWidth() - (mImageSelected.getWidth() * 0.1));
    params.height = (int) (mImageSelected.getHeight() - (mImageSelected.getHeight() * 0.1));
    mImageSelected.setLayoutParams(params);
}
 
开发者ID:Eduardo8609,项目名称:PhotoApp,代码行数:13,代码来源:ImageUtil.java

示例5: handleZoomIn

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Ação de ZoomIn - Aumentar imagem
 */
public static void handleZoomIn(ImageView mImageSelected) {
    if (mImageSelected.getWidth() > 800)
        return;

    ViewGroup.LayoutParams params = mImageSelected.getLayoutParams();
    params.width = (int) (mImageSelected.getWidth() + (mImageSelected.getWidth() * 0.1));
    params.height = (int) (mImageSelected.getHeight() + (mImageSelected.getHeight() * 0.1));
    mImageSelected.setLayoutParams(params);
}
 
开发者ID:Eduardo8609,项目名称:PhotoApp,代码行数:13,代码来源:ImageUtil.java

示例6: getImageViewSize

import android.widget.ImageView; //导入方法依赖的package包/类
private ImageSize getImageViewSize(ImageView imageView) {

        ImageSize imageSize = new ImageSize();
        ViewGroup.LayoutParams lp = imageView.getLayoutParams();
        DisplayMetrics displayMetrics = imageView.getContext().getResources().getDisplayMetrics();
        int width = imageView.getWidth();
        if (width <= 0) {
            width = lp.width;
        }
        if (width <= 0) {
            width = getImageViewFieldValue(imageView, "mMaxWidth");
        }
        if (width <= 0) {
            width = displayMetrics.widthPixels;
        }

        int height = imageView.getHeight();
        if (height <= 0) {
            height = lp.height;
        }
        if (height <= 0) {
            height = getImageViewFieldValue(imageView, "mMaxHeight");
        }
        if (height <= 0) {
            height = displayMetrics.heightPixels;
        }
        imageSize.width = width;
        imageSize.height = height;
        return imageSize;
    }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:31,代码来源:ImageLoader.java

示例7: overlay

import android.widget.ImageView; //导入方法依赖的package包/类
public void overlay(Canvas c, ImageView img) {
    if (arrowPos != ArrowPosition.NONE) {
        
        int x_border = (arrowPos == ArrowPosition.LEFT) ? 0 : img.getWidth();
        int x_inside = x_border + ((arrowPos == ArrowPosition.LEFT) ? 1 : -1 ) * (int)(img.getWidth() * 0.2f);
        int y_top = (int) (img.getHeight() * 0.2f);
        int y_bottom = (int) (img.getHeight() * 0.6f);
        c.save();
        
        Path path = new Path();   
        path.setFillType(Path.FillType.EVEN_ODD);
        path.moveTo(x_border, y_top);
        path.lineTo(x_inside, (y_top + y_bottom)/2);
        path.lineTo(x_border, y_bottom);
        path.lineTo(x_border, y_top);
        path.close();

        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setStrokeWidth(0);
        paint.setColor(android.graphics.Color.BLACK);     
        paint.setStyle(Paint.Style.FILL_AND_STROKE);
        paint.setAntiAlias(true);

        
        c.drawPath(path, paint);
        c.restore();
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:29,代码来源:QuickContactBadge.java

示例8: getTrashIconCenterX

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * 削除アイコンの中心X座標を取得します。
 *
 * @return 削除アイコンの中心X座標
 */
float getTrashIconCenterX() {
    final ImageView iconView = hasActionTrashIcon() ? mActionTrashIconView : mFixedTrashIconView;
    final float iconViewPaddingLeft = iconView.getPaddingLeft();
    final float iconWidth = iconView.getWidth() - iconViewPaddingLeft - iconView.getPaddingRight();
    final float x = mTrashIconRootView.getX() + iconViewPaddingLeft;
    return x + iconWidth / 2;
}
 
开发者ID:cheenid,项目名称:FLFloatingButton,代码行数:13,代码来源:TrashView.java

示例9: cropBitmap

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Crop the bitmap to only the part of the scansegment. The bitmap should only contain the part
 * that displays the MRZ of a travel document.
 * @param bitmap - The bitmap created from the camerapreview
 * @param scanSegment - Scansegment, the segment that should be scanned with OCR
 * @return
 */
public static Bitmap cropBitmap(Bitmap bitmap, ImageView scanSegment) {
    int startX = (int) scanSegment.getX();
    int startY = (int) scanSegment.getY();
    int width = scanSegment.getWidth();
    int length = scanSegment.getHeight();
    return Bitmap.createBitmap(bitmap, startX, startY, width, length);
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:15,代码来源:CameraFragmentUtil.java

示例10: transformPage

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public void transformPage(ImageView ivBg, float position, int direction) {
    ivBg.setScaleX(mScale);
    ivBg.setScaleY(mScale);
    float totalMoveWidth = ivBg.getWidth() * ((mScale - 1) / 2);
    int lastPosition = Math.round(position);
    float mFraction;
    if (lastPosition % 2 == 0) {
        mFraction = -1 * (float) Math.sin(Math.PI * position);
    } else {
        mFraction = (float) Math.sin(Math.PI * position);
    }
    ivBg.setTranslationY(totalMoveWidth * mFraction);
}
 
开发者ID:codeestX,项目名称:ECardFlow,代码行数:15,代码来源:CrossMoveAnimMode.java

示例11: checkMatrixBounds

import android.widget.ImageView; //导入方法依赖的package包/类
private void checkMatrixBounds() {
	final ImageView imageView = getImageView();
	if (null == imageView) {
		return;
	}

	final RectF rect = getDisplayRect(getDisplayMatrix());
	if (null == rect) {
		return;
	}

	final float height = rect.height(), width = rect.width();
	float deltaX = 0, deltaY = 0;

	final int viewHeight = imageView.getHeight();
	if (height <= viewHeight) {
		switch (mScaleType) {
		case FIT_START:
			deltaY = -rect.top;
			break;
		case FIT_END:
			deltaY = viewHeight - height - rect.top;
			break;
		default:
			deltaY = (viewHeight - height) / 2 - rect.top;
			break;
		}
	} else if (rect.top > 0) {
		deltaY = -rect.top;
	} else if (rect.bottom < viewHeight) {
		deltaY = viewHeight - rect.bottom;
	}

	final int viewWidth = imageView.getWidth();
	if (width <= viewWidth) {
		switch (mScaleType) {
		case FIT_START:
			deltaX = -rect.left;
			break;
		case FIT_END:
			deltaX = viewWidth - width - rect.left;
			break;
		default:
			deltaX = (viewWidth - width) / 2 - rect.left;
			break;
		}
		mScrollEdge = EDGE_BOTH;
	} else if (rect.left > 0) {
		mScrollEdge = EDGE_LEFT;
		deltaX = -rect.left;
	} else if (rect.right < viewWidth) {
		deltaX = viewWidth - rect.right;
		mScrollEdge = EDGE_RIGHT;
	} else {
		mScrollEdge = EDGE_NONE;
	}

	// Finally actually translate the matrix
	mSuppMatrix.postTranslate(deltaX, deltaY);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:61,代码来源:PhotoViewAttacher.java

示例12: getImageViewWidth

import android.widget.ImageView; //导入方法依赖的package包/类
private int getImageViewWidth(ImageView imageView) {
    if (null == imageView)
        return 0;
    return imageView.getWidth() - imageView.getPaddingLeft() - imageView.getPaddingRight();
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:6,代码来源:PhotoViewAttacher.java

示例13: optimizeMaxSize

import android.widget.ImageView; //导入方法依赖的package包/类
final void optimizeMaxSize(ImageView view) {
    if (width > 0 && height > 0) {
        maxWidth = width;
        maxHeight = height;
        return;
    }

    int screenWidth = DensityUtil.getScreenWidth();
    int screenHeight = DensityUtil.getScreenHeight();

    if (width < 0) {
        maxWidth = screenWidth * 3 / 2; //Integer.MAX_VALUE;
        compress = false;
    }
    if (height < 0) {
        maxHeight = screenHeight * 3 / 2; //Integer.MAX_VALUE;
        compress = false;
    }

    if (view == null && maxWidth <= 0 && maxHeight <= 0) {
        maxWidth = screenWidth;
        maxHeight = screenHeight;
    } else {
        int tempWidth = maxWidth;
        int tempHeight = maxHeight;

        if (view != null) {
            final ViewGroup.LayoutParams params = view.getLayoutParams();
            if (params != null) {

                if (tempWidth <= 0) {
                    if (params.width > 0) {
                        tempWidth = params.width;
                        if (this.width <= 0) {
                            this.width = tempWidth;
                        }
                    } else if (params.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
                        tempWidth = view.getWidth();
                    }
                }

                if (tempHeight <= 0) {
                    if (params.height > 0) {
                        tempHeight = params.height;
                        if (this.height <= 0) {
                            this.height = tempHeight;
                        }
                    } else if (params.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
                        tempHeight = view.getHeight();
                    }
                }
            }

            if (tempWidth <= 0) tempWidth = getImageViewFieldValue(view, "mMaxWidth");
            if (tempHeight <= 0) tempHeight = getImageViewFieldValue(view, "mMaxHeight");
        }

        if (tempWidth <= 0) tempWidth = screenWidth;
        if (tempHeight <= 0) tempHeight = screenHeight;

        maxWidth = tempWidth;
        maxHeight = tempHeight;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:65,代码来源:ImageOptions.java

示例14: getImageViewWidth

import android.widget.ImageView; //导入方法依赖的package包/类
private int getImageViewWidth(ImageView imageView) {
    return imageView.getWidth() - imageView.getPaddingLeft() - imageView.getPaddingRight();
}
 
开发者ID:BigSea001,项目名称:PhotoPickApp,代码行数:4,代码来源:PhotoViewAttacher.java

示例15: checkMatrixBounds

import android.widget.ImageView; //导入方法依赖的package包/类
private void checkMatrixBounds() {
    final ImageView imageView = getImageView();
    if (null == imageView) {
        return;
    }

    final RectF rect = getDisplayRect(getDisplayMatrix());
    if (null == rect) {
        return;
    }

    final float height = rect.height(), width = rect.width();
    float deltaX = 0, deltaY = 0;

    final int viewHeight = imageView.getHeight();
    if (height <= viewHeight) {
        switch (mScaleType) {
            case FIT_START:
                deltaY = -rect.top;
                break;
            case FIT_END:
                deltaY = viewHeight - height - rect.top;
                break;
            default:
                deltaY = (viewHeight - height) / 2 - rect.top;
                break;
        }
    } else if (rect.top > 0) {
        deltaY = -rect.top;
    } else if (rect.bottom < viewHeight) {
        deltaY = viewHeight - rect.bottom;
    }

    final int viewWidth = imageView.getWidth();
    if (width <= viewWidth) {
        switch (mScaleType) {
            case FIT_START:
                deltaX = -rect.left;
                break;
            case FIT_END:
                deltaX = viewWidth - width - rect.left;
                break;
            default:
                deltaX = (viewWidth - width) / 2 - rect.left;
                break;
        }
        mScrollEdge = EDGE_BOTH;
    } else if (rect.left > 0) {
        mScrollEdge = EDGE_LEFT;
        deltaX = -rect.left;
    } else if (rect.right < viewWidth) {
        deltaX = viewWidth - rect.right;
        mScrollEdge = EDGE_RIGHT;
    } else {
        mScrollEdge = EDGE_NONE;
    }

    // Finally actually translate the matrix
    mSuppMatrix.postTranslate(deltaX, deltaY);
}
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:61,代码来源:PhotoViewAttacher.java


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