本文整理匯總了Java中android.widget.ImageView.getTop方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.getTop方法的具體用法?Java ImageView.getTop怎麽用?Java ImageView.getTop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.getTop方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onGlobalLayout
import android.widget.ImageView; //導入方法依賴的package包/類
public void onGlobalLayout() {
ImageView imageView = this.getImageView();
if(null != imageView) {
if(this.mZoomEnabled) {
int top = imageView.getTop();
int right = imageView.getRight();
int bottom = imageView.getBottom();
int left = imageView.getLeft();
if(top != this.mIvTop || bottom != this.mIvBottom || left != this.mIvLeft || right != this.mIvRight) {
this.updateBaseMatrix(imageView.getDrawable());
this.mIvTop = top;
this.mIvRight = right;
this.mIvBottom = bottom;
this.mIvLeft = left;
}
} else {
this.updateBaseMatrix(imageView.getDrawable());
}
}
}
示例2: onGlobalLayout
import android.widget.ImageView; //導入方法依賴的package包/類
public void onGlobalLayout() {
ImageView imageView = getImageView();
if (imageView == null) {
return;
}
if (this.mZoomEnabled) {
int top = imageView.getTop();
int right = imageView.getRight();
int bottom = imageView.getBottom();
int left = imageView.getLeft();
if (top != this.mIvTop || bottom != this.mIvBottom || left != this.mIvLeft || right != this.mIvRight) {
updateBaseMatrix(imageView.getDrawable());
this.mIvTop = top;
this.mIvRight = right;
this.mIvBottom = bottom;
this.mIvLeft = left;
return;
}
return;
}
updateBaseMatrix(imageView.getDrawable());
}
示例3: onGlobalLayout
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public void onGlobalLayout() {
ImageView imageView = getImageView();
if (null != imageView) {
if (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;
}
} else {
updateBaseMatrix(imageView.getDrawable());
}
}
}
示例4: onGlobalLayout
import android.widget.ImageView; //導入方法依賴的package包/類
@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;
}
}
}
示例5: onGlobalLayout
import android.widget.ImageView; //導入方法依賴的package包/類
@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;
}
}
}
示例6: layoutImage
import android.widget.ImageView; //導入方法依賴的package包/類
void layoutImage(int i, int left, int top, int right, int bottom) {
final ImageView view = imageViews[i];
if (view.getLeft() == left && view.getTop() == top && view.getRight() == right
&& view.getBottom() == bottom) {
return;
}
view.layout(left, top, right, bottom);
}
示例7: onGlobalLayout
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public final void onGlobalLayout() {
ImageView imageView = getImageView();
if (null != imageView) {
if (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;
}
} else {
updateBaseMatrix(imageView.getDrawable());
}
}
}
示例8: onGlobalLayout
import android.widget.ImageView; //導入方法依賴的package包/類
@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;
}
}
}
示例9: getTranslationInBounds
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* Given a proposed translation, this will check to ensure that (a) it will not translate the
* drawable if it has not scaled to larger than the view dimensions and (b) it will not
* translate the drawable edges back inside the view bounds if it has scaled larger than the
* view dimensions.
*
* @param translation the proposed translation
* @param imageView the view containing the drawable to translate
* @param matrix the matrix that is currently applied to the drawable
* @return the proposed translation if satisfying all criteria, else a corrected version that
* satisfies them.
*/
private static PointF getTranslationInBounds(PointF translation,
@Nullable ImageView imageView,
@Nullable Matrix matrix) {
if (imageView == null || imageView.getDrawable() == null || matrix == null) {
return translation;
}
RectF drawableBounds = new RectF(imageView.getDrawable().copyBounds());
RectF viewBounds = new RectF(
imageView.getLeft(),
imageView.getTop(),
imageView.getRight(),
imageView.getBottom());
// Update the drawable bounds according to the current matrix
matrix.mapRect(drawableBounds);
PointF correctedTranslation = new PointF();
if (drawableBounds.width() < viewBounds.width()) {
// Don't allow additional translations if still within the view bounds
correctedTranslation.x = 0;
} else {
// Don't translate more than the current spacing between the drawable and view edges
if (translation.x > 0) {
float leftGap = viewBounds.left - drawableBounds.left;
correctedTranslation.x = translation.x < leftGap ? translation.x : leftGap;
} else {
float rightGap = viewBounds.right - drawableBounds.right;
correctedTranslation.x = translation.x > rightGap ? translation.x : rightGap;
}
}
if (drawableBounds.height() < viewBounds.height()) {
// Don't allow additional translations if still within the view bounds
correctedTranslation.y = 0;
} else {
// Don't translate more than the current spacing between the drawable and view edges
if (translation.y > 0) {
float topGap = viewBounds.top - drawableBounds.top;
correctedTranslation.y = translation.y < topGap ? translation.y : topGap;
} else {
float bottomGap = viewBounds.bottom - drawableBounds.bottom;
correctedTranslation.y = translation.y > bottomGap ? translation.y : bottomGap;
}
}
return correctedTranslation;
}