本文整理了Java中android.widget.ImageView.getWidth()
方法的一些代码示例,展示了ImageView.getWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.getWidth()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:getWidth
暂无
代码示例来源:origin: stackoverflow.com
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
super.onWindowFocusChanged(hasFocus);
ImageView img = (ImageView) findViewById(R.id.img);
Log.d(TAG, "width : " + img.getWidth());
}
代码示例来源:origin: chrisbanes/PhotoView
private int getImageViewWidth(ImageView imageView) {
return imageView.getWidth() - imageView.getPaddingLeft() - imageView.getPaddingRight();
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onProvideShadowMetrics(Point shadowSize,
Point shadowTouchPoint) {
shadowSize.set(iv.getWidth()/8, iv.getHeight()/8);
shadowTouchPoint.set(shadowSize.x/2, shadowSize.y/2);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onProvideShadowMetrics(Point shadowSize,
Point shadowTouchPoint) {
shadowSize.set(iv.getWidth()/8, iv.getHeight()/8);
shadowTouchPoint.set(shadowSize.x/2, shadowSize.y/2);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onProvideShadowMetrics(Point shadowSize,
Point shadowTouchPoint) {
shadowSize.set(iv.getWidth()/8, iv.getHeight()/8);
shadowTouchPoint.set(shadowSize.x/2, shadowSize.y/2);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onProvideShadowMetrics(Point shadowSize,
Point shadowTouchPoint) {
shadowSize.set(iv.getWidth()/8, iv.getHeight()/8);
shadowTouchPoint.set(shadowSize.x/2, shadowSize.y/2);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onProvideShadowMetrics(Point shadowSize,
Point shadowTouchPoint) {
shadowSize.set(iv.getWidth()/8, iv.getHeight()/8);
shadowTouchPoint.set(shadowSize.x/2, shadowSize.y/2);
}
代码示例来源:origin: androidquery/androidquery
private int getWidth(ImageView iv){
int width = 0;
LayoutParams lp = iv.getLayoutParams();
if(lp != null) width = lp.width;
if(width <= 0){
width = iv.getWidth();
}
if(width > 0){
width = width - iv.getPaddingLeft() - iv.getPaddingRight();
}
return width;
}
代码示例来源:origin: wangdan/AisenWeiBo
public final void onFling(float startX, float startY, float velocityX, float velocityY) {
if (DEBUG) {
Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY);
}
ImageView imageView = getImageView();
if (hasDrawable(imageView)) {
mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
mCurrentFlingRunnable.fling(imageView.getWidth(), imageView.getHeight(), (int) velocityX, (int) velocityY);
imageView.post(mCurrentFlingRunnable);
}
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
@Override
public final void onFling(float startX, float startY, float velocityX,
float velocityY) {
if (DEBUG) {
Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY
+ " Vx: " + velocityX + " Vy: " + velocityY);
}
ImageView imageView = getImageView();
if (hasDrawable(imageView)) {
mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
mCurrentFlingRunnable.fling(imageView.getWidth(),
imageView.getHeight(), (int) velocityX, (int) velocityY);
imageView.post(mCurrentFlingRunnable);
}
}
代码示例来源:origin: jeasonlzy/NineGridView
@Override
public void onAnimationUpdate(ValueAnimator animation) {
long duration = animation.getDuration();
long playTime = animation.getCurrentPlayTime();
float fraction = duration > 0 ? (float) playTime / duration : 1f;
if (fraction > 1) fraction = 1;
view.setTranslationX(evaluateInt(fraction, imageData.imageViewX + imageData.imageViewWidth / 2 - imageView.getWidth() / 2, 0));
view.setTranslationY(evaluateInt(fraction, imageData.imageViewY + imageData.imageViewHeight / 2 - imageView.getHeight() / 2, 0));
view.setScaleX(evaluateFloat(fraction, vx, 1));
view.setScaleY(evaluateFloat(fraction, vy, 1));
view.setAlpha(fraction);
rootView.setBackgroundColor(evaluateArgb(fraction, Color.TRANSPARENT, Color.BLACK));
}
});
代码示例来源:origin: square/picasso
@Test public void waitsForAnotherLayoutIfWidthOrHeightIsZero() {
ImageView target = mockFitImageViewTarget(true);
when(target.getWidth()).thenReturn(0);
when(target.getHeight()).thenReturn(0);
RequestCreator creator = mock(RequestCreator.class);
DeferredRequestCreator request = new DeferredRequestCreator(creator, target, null);
request.onPreDraw();
verify(target.getViewTreeObserver(), never()).removeOnPreDrawListener(request);
verifyZeroInteractions(creator);
}
代码示例来源:origin: square/picasso
@Test
public void intoImageViewWithFitAndNoDimensionsQueuesDeferredImageViewRequest() {
ImageView target = mockFitImageViewTarget(true);
when(target.getWidth()).thenReturn(0);
when(target.getHeight()).thenReturn(0);
new RequestCreator(picasso, URI_1, 0).fit().into(target);
verify(picasso, never()).enqueueAndSubmit(any(Action.class));
verify(picasso).defer(eq(target), any(DeferredRequestCreator.class));
}
代码示例来源:origin: androidquery/androidquery
private void draw(Canvas canvas, ImageView iv, Bitmap bm){
Matrix m = getMatrix(iv, bm);
if(m != null){
int vpad = iv.getPaddingTop() + iv.getPaddingBottom();
int hpad = iv.getPaddingLeft() + iv.getPaddingRight();
if(vpad > 0 || hpad > 0){
canvas.clipRect(0, 0, iv.getWidth() - hpad, iv.getHeight() - vpad);
}
canvas.drawBitmap(bm, m, getPaint());
}
if(!adjusted){
adjust(iv, bm, true);
}
}
代码示例来源:origin: square/picasso
@Test
public void intoImageViewWithFitAndDimensionsQueuesImageViewRequest() {
ImageView target = mockFitImageViewTarget(true);
when(target.getWidth()).thenReturn(100);
when(target.getHeight()).thenReturn(100);
new RequestCreator(picasso, URI_1, 0).fit().into(target);
verify(picasso).enqueueAndSubmit(actionCaptor.capture());
assertThat(actionCaptor.getValue()).isInstanceOf(ImageViewAction.class);
}
代码示例来源:origin: square/picasso
@Override public boolean onPreDraw() {
ImageView target = this.target;
ViewTreeObserver vto = target.getViewTreeObserver();
if (!vto.isAlive()) {
return true;
}
int width = target.getWidth();
int height = target.getHeight();
if (width <= 0 || height <= 0) {
return true;
}
target.removeOnAttachStateChangeListener(this);
vto.removeOnPreDrawListener(this);
this.creator.unfit().resize(width, height).into(target, callback);
return true;
}
代码示例来源:origin: square/picasso
@Test public void preDrawSubmitsRequestAndCleansUp() {
Picasso picasso = mock(Picasso.class);
when(picasso.transformRequest(any(Request.class))).thenAnswer(TRANSFORM_REQUEST_ANSWER);
RequestCreator creator = new RequestCreator(picasso, URI_1, 0);
ImageView target = mockFitImageViewTarget(true);
when(target.getWidth()).thenReturn(100);
when(target.getHeight()).thenReturn(100);
ViewTreeObserver observer = target.getViewTreeObserver();
DeferredRequestCreator request = new DeferredRequestCreator(creator, target, null);
request.onPreDraw();
verify(observer).removeOnPreDrawListener(request);
verify(picasso).enqueueAndSubmit(actionCaptor.capture());
Action value = actionCaptor.getValue();
assertThat(value).isInstanceOf(ImageViewAction.class);
assertThat(value.request.targetWidth).isEqualTo(100);
assertThat(value.request.targetHeight).isEqualTo(100);
}
}
代码示例来源:origin: wangdan/AisenWeiBo
@Override
public boolean onPreDraw() {
img.getViewTreeObserver().removeOnPreDrawListener(this);
width = img.getWidth();
ActivityHelper.putIntShareData(GlobalContext.getInstance(), "WallpaperWidth", width);
onBindData(convertView, data, position);
return true;
}
代码示例来源:origin: north2016/T-MVP
void backwards(int position, float positionOffset) {
if (isSkip) return;
// Log.e("DEBUG-WCL", "backwards-positionOffset: " + positionOffset);
int width = mTargetImage.getWidth();
mOutgoingImage.setTranslationX((1 - positionOffset) * (FACTOR * width));
mTargetImage.setTranslationX(-(positionOffset) * (FACTOR * width));
int color = BaseUtils.evaluate(1 - positionOffset, mColors[position + 1], mColors[position]);
collapsingToolbar.setContentScrimColor(color);
collapsingToolbar.setStatusBarScrimColor(color);
mTargetImage.setAlpha(1 - positionOffset);
}
代码示例来源:origin: north2016/T-MVP
void forward(int position, float positionOffset) {
if (isSkip) return;
// Log.e("DEBUG-WCL", "forward-positionOffset: " + positionOffset);
int width = mTargetImage.getWidth();
mOutgoingImage.setTranslationX(-positionOffset * (FACTOR * width));
mTargetImage.setTranslationX((1 - positionOffset) * (FACTOR * width));
int color = BaseUtils.evaluate(positionOffset, mColors[position], mColors[position + 1]);
collapsingToolbar.setContentScrimColor(color);
collapsingToolbar.setStatusBarScrimColor(color);
mTargetImage.setAlpha(positionOffset);
}
内容来源于网络,如有侵权,请联系作者删除!