android.widget.ImageView.getTop()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中android.widget.ImageView.getTop()方法的一些代码示例,展示了ImageView.getTop()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.getTop()方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:getTop

ImageView.getTop介绍

暂无

代码示例

代码示例来源:origin: jiangqqlmj/FastDev4Android

@Override
public final void onGlobalLayout() {
  ImageView imageView = getImageView();
  if (null != imageView && mZoomEnabled) {
    final int top = imageView.getTop();
    final int right = imageView.getRight();
    final int bottom = imageView.getBottom();
    final int left = imageView.getLeft();
    /**
     * We need to check whether the ImageView's bounds have changed.
     * This would be easier if we targeted API 11+ as we could just use
     * View.OnLayoutChangeListener. Instead we have to replicate the
     * work, keeping track of the ImageView's bounds and then checking
     * if the values change.
     */
    if (top != mIvTop || bottom != mIvBottom || left != mIvLeft
        || right != mIvRight) {
      // Update our base matrix, as the bounds have changed
      updateBaseMatrix(imageView.getDrawable());
      // Update values as something has changed
      mIvTop = top;
      mIvRight = right;
      mIvBottom = bottom;
      mIvLeft = left;
    }
  }
}

代码示例来源:origin: wangdan/AisenWeiBo

public final void onGlobalLayout() {
  ImageView imageView = getImageView();
  if (null != imageView && mZoomEnabled) {
    final int top = imageView.getTop();
    final int right = imageView.getRight();
    final int bottom = imageView.getBottom();
    final int left = imageView.getLeft();
    /**
     * We need to check whether the ImageView's bounds have changed. This would be easier if
     * we targeted API 11+ as we could just use View.OnLayoutChangeListener. Instead we have
     * to replicate the work, keeping track of the ImageView's bounds and then checking if
     * the values change.
     */
    if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
      // Update our base matrix, as the bounds have changed
      updateBaseMatrix(imageView.getDrawable());
      // Update values as something has changed
      mIvTop = top;
      mIvRight = right;
      mIvBottom = bottom;
      mIvLeft = left;
    }
  }
}

代码示例来源:origin: wangdan/AisenWeiBo

public final void onGlobalLayout() {
  ImageView imageView = getImageView();
  if (null != imageView && mZoomEnabled) {
    final int top = imageView.getTop();
    final int right = imageView.getRight();
    final int bottom = imageView.getBottom();
    final int left = imageView.getLeft();
    /**
     * We need to check whether the ImageView's bounds have changed. This would be easier if
     * we targeted API 11+ as we could just use View.OnLayoutChangeListener. Instead we have
     * to replicate the work, keeping track of the ImageView's bounds and then checking if
     * the values change.
     */
    if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
      // Update our base matrix, as the bounds have changed
      updateBaseMatrix(imageView.getDrawable());
      // Update values as something has changed
      mIvTop = top;
      mIvRight = right;
      mIvBottom = bottom;
      mIvLeft = left;
    }
  }
}

代码示例来源:origin: stackoverflow.com

private void getPositionOfImageView(){                
   ImageView imageView = (ImageView) findViewById(R.id.imageView);
   // Top position view relative to parent (Button and ImageView have same parent)
   int topCoordinate = imageView.getTop();
   adjustButton(topCoordinate);
 }

代码示例来源:origin: stackoverflow.com

ImageView img = (ImageView) findViewById(R.id.image_view);
img.getViewTreeObserver().addOnGlobalLayoutListener(
      new ViewTreeObserver.OnGlobalLayoutListener(){

        @Override
        public void onGlobalLayout() {

          int left = img.getLeft();
          int top = img.getTop();
          //Toast the height and top...
        }

      });

代码示例来源:origin: stackoverflow.com

ImageView iv = (ImageView) findViewById(R.id.imageView);

iv.animate().translationY(-iv.getTop()).setDuration(1000); // 1000 ms

代码示例来源:origin: stackoverflow.com

//any image view
//must be assigned before use by findViewByID(int id)
ImageView image_view = null;
@Override
public boolean onTouchEvent(MotionEvent event) {
  //boundary of your image view
  Rect rect = new Rect(image_view.getLeft(),image_view.getTop(),image_view.getRight(),image_view.getBottom());
  //if point is inside rect then test_collision = true, else test_collision = false
  boolean test_collision = rect.contains((int)event.getX(), (int)event.getY());
  return super.onTouchEvent(event);
}

代码示例来源:origin: stackoverflow.com

Rect rect = new Rect();
 ImageView iV = new ImageView();
 rect.left = iV.getLeft();
 rect.top = iV.getTop();
 rect.bottom = iV.getBottom();
 rect.right = iV.getRight();

代码示例来源:origin: Cleveroad/PlayWidget

private int calculateFabTransitionY() {
  return mSmallDiffuserImageView.getTop() + mSmallDiffuserImageView.getHeight() / 2 - mPlayButton.getTop() - mPlayButton.getHeight() / 2 + getPaddingTop();
}

代码示例来源:origin: stackoverflow.com

ImageView iv = //Code to find the image view
Rect rect = new Rect(iv.getLeft(), iv.getTop(), iv.getRight(), iv.getBottom());
lv.requestChildRectangleOnScreen(lv, rect, false);

代码示例来源:origin: w446108264/ScrollableLayout

@Override
  public void onScroll(int translationY, int maxY) {
    translationY = -translationY;
    if (titleMaxScrollHeight == 0) {
      titleMaxScrollHeight = ((View) tv_title.getParent()).getBottom() - tv_title.getTop();
      maxScrollHeight = hearderMaxHeight + titleMaxScrollHeight;
    }
    if (hearderMaxHeight == 0) {
      hearderMaxHeight = tv_name.getTop();
      maxScrollHeight = hearderMaxHeight + titleMaxScrollHeight;
    }
    if (avatarTop == 0) {
      avatarTop = iv_avatar.getTop();
    }
    int alpha = 0;
    int baseAlpha = 60;
    if (0 > avatarTop + translationY) {
      alpha = Math.min(255, (int) (Math.abs(avatarTop + translationY) * (255 - baseAlpha) / (hearderMaxHeight - avatarTop) + baseAlpha));
      iv_spit.setVisibility(View.VISIBLE);
    } else {
      iv_spit.setVisibility(View.GONE);
    }
    iv_spit.getBackground().setAlpha(alpha);
    tv_title.setTranslationY(Math.max(0, maxScrollHeight + translationY));
  }
});

代码示例来源:origin: yukuku/androidbible

protected void moveAlphaCursor() {
  final int measuredHeight = this.viewAlphaCheckered.getMeasuredHeight();
  float y = measuredHeight - ((this.getAlpha() * measuredHeight) / 255.f);
  final RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.viewAlphaCursor.getLayoutParams();
  layoutParams.leftMargin = (int) (this.viewAlphaCheckered.getLeft() - Math.floor(this.viewAlphaCursor.getMeasuredWidth() / 2) - this.viewContainer.getPaddingLeft());
  layoutParams.topMargin = (int) ((this.viewAlphaCheckered.getTop() + y) - Math.floor(this.viewAlphaCursor.getMeasuredHeight() / 2) - this.viewContainer.getPaddingTop());
  this.viewAlphaCursor.setLayoutParams(layoutParams);
}

代码示例来源:origin: konradrenner/kolabnotes-android

protected void moveAlphaCursor() {
  final int measuredHeight = this.viewAlphaCheckered.getMeasuredHeight();
  float y = measuredHeight - ((this.getAlpha() * measuredHeight) / 255.f);
  final RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.viewAlphaCursor.getLayoutParams();
  layoutParams.leftMargin = (int) (this.viewAlphaCheckered.getLeft() - Math.floor(this.viewAlphaCursor.getMeasuredWidth() / 2) - this.viewContainer.getPaddingLeft());
  layoutParams.topMargin = (int) ((this.viewAlphaCheckered.getTop() + y) - Math.floor(this.viewAlphaCursor.getMeasuredHeight() / 2) - this.viewContainer.getPaddingTop());
  this.viewAlphaCursor.setLayoutParams(layoutParams);
}

代码示例来源:origin: yukuku/ambilwarna

protected void moveAlphaCursor() {
  final int measuredHeight = this.viewAlphaCheckered.getMeasuredHeight();
  float y = measuredHeight - ((this.getAlpha() * measuredHeight) / 255.f);
  final RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.viewAlphaCursor.getLayoutParams();
  layoutParams.leftMargin = (int) (this.viewAlphaCheckered.getLeft() - Math.floor(this.viewAlphaCursor.getMeasuredWidth() / 2) - this.viewContainer.getPaddingLeft());
  layoutParams.topMargin = (int) ((this.viewAlphaCheckered.getTop() + y) - Math.floor(this.viewAlphaCursor.getMeasuredHeight() / 2) - this.viewContainer.getPaddingTop());
  this.viewAlphaCursor.setLayoutParams(layoutParams);
}

代码示例来源:origin: ckj375/Android-Sticker

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  if (requestCode == REQUEST_FOR_PICTURE && resultCode == RESULT_OK) {
    String imgPath = data.getStringExtra(MaterialActivity.MATERIAL_PATH);
    // 贴图容器中心点
    int centerX = (img.getLeft() + img.getRight()) / 2;
    int centerY = (img.getTop() + img.getBottom()) / 2;
    Log.v(TAG, "centerX=" + centerX + "  centerY=" + centerY);
    StickerView view = new StickerView(mContext, imgPath);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    view.setLayoutParams(params);
    mStickerLayout.addView(view);
  }
}

代码示例来源:origin: stackoverflow.com

ImageView view = .....
int centerX = (view.getLeft() + view.getRight())/2;
int centerY = (view.getTop() + view.getBottom())/2;

代码示例来源:origin: stackoverflow.com

ImageView imageView=(ImageView)findViewById(R.id.dot_image);
   int x=imageView.getRight()-imageView.getLeft();
   int y=imageView.getBottom()-imageView.getTop();
   TranslateAnimation translate = new TranslateAnimation(
       Animation.ABSOLUTE,x, Animation.ABSOLUTE,
       x, Animation.ABSOLUTE,y,
       Animation.ABSOLUTE,yPosition);
   translate.setDuration(150);
   translate.setFillEnabled(true);
   translate.setFillAfter(true);
   imageView.startAnimation(translate);

代码示例来源:origin: wuyr/CatchPiggy

private void layoutDropView(Item item) {
  MyLayoutParams layoutParams = (MyLayoutParams) mDropView.getLayoutParams();
  if (layoutParams.isDrag) {
    mDropView.layout(mDropView.getLeft() + layoutParams.x, mDropView.getTop() + layoutParams.y,
        mDropView.getRight() + layoutParams.x, mDropView.getBottom() + layoutParams.y);
  } else {
    mDropView.layout(0, 0, mDropView.getLayoutParams().width, mDropView.getLayoutParams().height);
    mDropView.layout((int) item.getX() - (mDropView.getWidth() - item.getWidth()),
        item.getBottom() - mDropView.getHeight(), (int) item.getX() + mDropView.getWidth(), item.getBottom());
  }
}

代码示例来源:origin: stackoverflow.com

if (beaconBitmap == null)
 {
   /* Calculamos las dimensiones si no está creado el bitmap */
   beaconView.invalidate();
   beaconView.refreshDrawableState();
   beaconView.measure(
       MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
       MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
   beaconView.layout(0, 0, beaconView.getMeasuredWidth(),
       beaconView.getMeasuredHeight());
   ImageView ivBeaconType = (ImageView) beaconView
       .findViewById(R.id.ivBeaconType);
   Rect beaconIconArea = new Rect(ivBeaconType.getLeft(),
       ivBeaconType.getTop(), ivBeaconType.getRight(),
       ivBeaconType.getBottom());
   beaconBitmapCenterX = beaconIconArea.centerX();
   beaconBitmapCenterY = beaconIconArea.centerY();
 }

代码示例来源:origin: vpaliy/android-material-motion

private void setUpReveal() {
 int w = panel.getWidth();
 int h = panel.getHeight();
 final int endRadius = (int) Math.hypot(w, h);
 final int cx = (int) (actionButton.getX() + actionButton.getWidth() / 2);
 final int cy = (int) (actionButton.getY() + actionButton.getHeight() / 2 - background.getTop());
 final float deltaX = cx - (playPause.getLeft() + playPause.getWidth() / 2);
 final float deltaY = (cy - getResources().getDimension(R.dimen.play_pause_size) / 2) - (playPause.getTop());
 playPause.setTranslationX(deltaX);
 playPause.setTranslationY(deltaY);
 revealAnimator = ViewAnimationUtils.createCircularReveal(panel, cx, cy, actionButton.getHeight(), endRadius);
 revealAnimator.addListener(new AnimatorListenerAdapter() {
  @Override
  public void onAnimationStart(Animator animation) {
   panel.setVisibility(View.VISIBLE);
   actionButton.setVisibility(View.INVISIBLE);
   fadeInOutViews(0, duration(R.integer.fade_in_duration));
  }
 });
 revealAnimator.setDuration(duration(R.integer.conceal_duration) / 2);
 revealAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
}

相关文章

ImageView类方法