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

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

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

ImageView.getX介绍

暂无

代码示例

代码示例来源:origin: brianwernick/ExoMedia

@Override
public void onAnimationEnd(Animation animation) {
  rippleIndicator.setX(rippleIndicator.getX() + xDelta);
  rippleIndicator.clearAnimation();
}

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

EditText textDistance = (EditText) findViewById(R.id.distance);
ImageView image1 = (ImageView) findViewById(R.id.image1);
ImageView image2 = (ImageView) findViewById(R.id.image2);
float distance = image2.getX()- image1.getX()+image1.getWidth();
textDistance.setText((String.valueOf(distance));

代码示例来源:origin: skydoves/ColorPickerView

/**
 * gets a selector's selected coordinate x.
 *
 * @return a selected coordinate x.
 */
public float getSelectorX() {
  return selector.getX() - (selector.getMeasuredWidth() / 2);
}

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

ImageView image1 = (ImageView) findViewById(R.id.imageView);
ImageView image2 = (ImageView) findViewById(R.id.imageView1);
ImageView image3 = (ImageView) findViewById(R.id.imageView2);
image.setX(0); // set it at starting
image2.setX(image.getX()+image.getWidth()); setting it as first image starting X + Width = end of it.
image3.setX(image2.getX()+image2.getWidth());  same like the previous one.

代码示例来源:origin: skydoves/ColorPickerPreference

public float getSelectorX() {
 return selector.getX() - getSelectorHalfWidth();
}

代码示例来源:origin: safetysystemtechnology/audio-recorder-button

private void moveImageToBack() {
  this.mImageButton.setAlpha(0.5f);
  final ValueAnimator positionAnimator =
      ValueAnimator.ofFloat(this.mImageView.getX(), this.initialX);
  positionAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
  positionAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
      float x = (Float) animation.getAnimatedValue();
      mImageView.setX(x);
      if (mImageView.getX() > DEFAULT_REMOVE_ICON_SIZE){
        unRevealSizeToRemove();
      }
    }
  });
  positionAnimator.setDuration(200);
  positionAnimator.start();
}

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

public boolean collision(ImageView a, ImageView b){
  float bl = a.getY();
  float bt = a.getX();
  float br = a.getWidth() + bl;
  float bb = a.getHeight() + bt;
  float pl = b.getY();
  float pt = b.getX();
  float pr = b.getWidth() + pl;
  float pb = b.getHeight() + pt;
  if (bl <= pr && bl >= pl && bt >= pt && bt <= pb) {
    return true;

  } else if (br >= pl && br <= pr && bb >= pt && bb <= pb) {
    return true;
  } else if (bt <= pb && bt >= pt && br >= pl && br <= pr) {
    return true;
  } else if (bb >= pt && bb <= pb && bl >= pl && bl <= pr) {
    return true;
  }
  return false;
}

代码示例来源:origin: safetysystemtechnology/audio-recorder-button

@Override
  public void onAnimationUpdate(ValueAnimator animation) {
    float x = (Float) animation.getAnimatedValue();
    mImageView.setX(x);
    if (mImageView.getX() > DEFAULT_REMOVE_ICON_SIZE){
      unRevealSizeToRemove();
    }
  }
});

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

public boolean collision(ImageView a, ImageView b){
  float bl = a.getY();
  float bt = a.getX();
  float br = a.getWidth() + bl;
  float bb = a.getHeight() + bt;
  float pl = b.getY();
  float pt = b.getX();
  float pr = b.getWidth() + pl;
  float pb = b.getHeight() + pt;
  if (bl <= pr && bl >= pl && bt >= pt && bt <= pb) {
    return true;

  } else if (br >= pl && br <= pr && bb >= pt && bb <= pb) {
    return true;
  } else if (bt <= pb && bt >= pt && br >= pl && br <= pr) {
    return true;
  } else if (bb >= pt && bb <= pb && bl >= pl && bl <= pr) {
    return true;
  }
  return false;
}

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

ImageView iv = (ImageView)findViewById(R.id.image_view);
Drawable d = iv.getDrawable();
Rect bounds = d.getBounds();
int top = iv.getY() + bounds.top;
int left = iv.getX() + bounds.left;

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

final ImageView temp = (ImageView) findViewById(R.id.fivetwo);
ViewTreeObserver vto = temp.getViewTreeObserver(); 
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { 
  @Override 
  public void onGlobalLayout() { 
    temp.getViewTreeObserver().removeGlobalOnLayoutListener(this); 
    int x  = temp.getX();
    int y = temp.getY();
    Log.v(TAG, String.format("X:%d Y:%d",x,y);
  } 
});

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

final ImageView imageview = (ImageView) findViewById(R.id.imageView);
 final ValueAnimator translateAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
 ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(imageview, "rotation", 0f, 90f);
 final AnimatorSet animatorSet = new AnimatorSet();
 animatorSet.playTogether(translateAnimator, rotateAnimator);
 animatorSet.setDuration(4000);
 final float x = imageview.getX();
 final float y = imageview.getY();
 translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
   @Override
   public void onAnimationUpdate(ValueAnimator valueAnimator) {
     float t = (Float) translateAnimator.getAnimatedValue();
     imageview.setTranslationX(x + t*100);    // do your own
     imageview.setTranslationY(y + t*100);    // thing here
   }
 });
 imageview.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View view) {
     animatorSet.start();
   }
 });

代码示例来源:origin: skydoves/ColorPickerView

private void onTouchReceived(MotionEvent event) {
  float eventX = event.getX();
  float left = selector.getMeasuredWidth();
  float right = getMeasuredWidth() - selector.getMeasuredWidth();
  if (eventX < left) eventX = left;
  if (eventX > right) eventX = right;
  selectorPosition = (eventX - left) / (right - left);
  Point snapPoint = new Point((int) event.getX(), (int) event.getY());
  selectedX = snapPoint.x;
  selector.setX(snapPoint.x - (selector.getMeasuredWidth() / 2));
  if (colorPickerView.getActionMode() == ActionMode.LAST) {
    if (event.getAction() == MotionEvent.ACTION_UP) {
      colorPickerView.fireColorListener(assembleColor(), true);
    }
  } else {
    colorPickerView.fireColorListener(assembleColor(), true);
  }
  int maxPos = getMeasuredWidth() - selector.getMeasuredWidth();
  if (selector.getX() >= maxPos) selector.setX(maxPos);
  if (selector.getX() <= 0) selector.setX(0);
}

代码示例来源:origin: skydoves/ColorPickerView

public void updateSelectorX(int x) {
  float left = selector.getMeasuredWidth();
  float right = getMeasuredWidth() - selector.getMeasuredWidth();
  selectorPosition = (x - left) / (right - left);
  selector.setX(x - (selector.getMeasuredWidth() / 2));
  selectedX = x;
  int maxPos = getMeasuredWidth() - selector.getMeasuredWidth();
  if (selector.getX() >= maxPos) selector.setX(maxPos);
  if (selector.getX() <= 0) selector.setX(0);
  colorPickerView.fireColorListener(assembleColor(), false);
}

代码示例来源:origin: ianhanniballake/TripleSolitaire

/**
 * Gets the screen location for the top card in the waste
 *
 * @return The exact (x,y) position of the top card in the waste
 */
private Point getWasteLoc() {
  final RelativeLayout waste = findViewById(R.id.waste);
  final ImageView waste1View = findViewById(R.id.waste1);
  final float x = waste.getX() + waste.getPaddingLeft() + waste1View.getX() + waste1View.getPaddingLeft();
  final float y = waste.getY() + waste.getPaddingTop() + waste1View.getY() + waste1View.getPaddingTop();
  return new Point((int) x, (int) y);
}

代码示例来源:origin: ianhanniballake/TripleSolitaire

/**
 * Gets the screen location for the given foundation
 *
 * @param foundationIndex Negative One-based index (-1 through -12)
 * @return The exact (x,y) position of the foundation
 */
private Point getFoundationLoc(final int foundationIndex) {
  final RelativeLayout foundationLayout = findViewById(R.id.foundation);
  final ImageView foundationView = findViewById(getResources().getIdentifier(
      "foundation" + (foundationIndex + 1), "id", getPackageName()));
  final float x = foundationView.getX() + foundationView.getPaddingLeft() + foundationLayout.getX()
      + foundationLayout.getPaddingLeft();
  final float y = foundationView.getY() + foundationView.getPaddingTop() + foundationLayout.getY()
      + foundationLayout.getPaddingTop();
  return new Point((int) x, (int) y);
}

代码示例来源:origin: albert-lii/ImageViewer

@Override
  public void onClick(View v) {
    imagePager.getViewData().setTargetX(imageView.getX());
    // 此处注意,获取 Y 轴坐标时,需要根据实际情况来处理《状态栏》的高度,判断是否需要计算进去
    imagePager.getViewData().setTargetY(imageView.getY());
    imagePager.getViewData().setTargetWidth(imageView.getWidth());
    imagePager.getViewData().setTargetHeight(imageView.getHeight());
    imagePager.start(new OnTransCallback() {
      @Override
      public void onStart() {
      }
      @Override
      public void onRunning(float progress) {
      }
      @Override
      public void onEnd() {
        setTransparentStatusBar(R.color.colorBlack);
      }
    });
  }
});

代码示例来源:origin: Rkhcy/PhysicsBasedAnimation

@Override
  public void onClick(View view) {
    final SpringAnimation springAnimation = new SpringAnimation(img, DynamicAnimation.X);
    final SpringForce springForce = new SpringForce();
    springForce.setDampingRatio(SpringForce.DAMPING_RATIO_HIGH_BOUNCY);
    springForce.setStiffness(SpringForce.STIFFNESS_VERY_LOW);
    springForce.setFinalPosition(img.getX());
    springAnimation.setSpring(springForce);
    springAnimation.setStartVelocity(2000);
    springAnimation.start();
  }
});

代码示例来源:origin: Rkhcy/PhysicsBasedAnimation

@Override
  public void onClick(View view) {
    SpringAnimation springAnimation
        = new SpringAnimation(img, DynamicAnimation.X);
    SpringForce springForce = new SpringForce();
    springForce.setFinalPosition(img.getX());
    springForce.setDampingRatio(SpringForce.DAMPING_RATIO_HIGH_BOUNCY);
    springForce.setStiffness(SpringForce.STIFFNESS_LOW);
    springAnimation.setSpring(springForce);
    springAnimation.setStartVelocity(2000);
    springAnimation.start();
    img.setImageResource(R.drawable.ic_sentiment_very_satisfied_black_56dp);
    springAnimation.addEndListener(new DynamicAnimation.OnAnimationEndListener() {
      @Override
      public void onAnimationEnd(DynamicAnimation animation, boolean canceled, float value, float velocity) {
        img.setImageResource(R.drawable.ic_sentiment_neutral_black_56dp);
      }
    });
  }
});

代码示例来源:origin: sealtalk/sealtalk-android

public void onMoreButtonClick(View view) {
  optionMenu = new CallOptionMenu(MultiVideoCallActivity.this);
  optionMenu.setHandUpvisibility(callSession.getUserType() == RongCallCommon.CallUserType.OBSERVER);
  optionMenu.setOnItemClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      int i = v.getId();
      if (i == R.id.voipItemAdd) {
        addButtionClickEvent();
      } else if (i == R.id.voipItemWhiteboard) {
        onWhiteBoardClick();
      } else if (i == R.id.voipItemHandup) {
        onRequestNormalUserClick();
      }
      optionMenu.dismiss();
    }
  });
  optionMenu.showAsDropDown(moreButton, (int) moreButton.getX(), 0);
}

相关文章

ImageView类方法