下面列出了android.widget.ImageView#getX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void maybeInitProperties(ImageView child, View dependency) {
if (mStartYPosition == 0)
mStartYPosition = (int) (dependency.getY());
if (mFinalYPosition == 0)
mFinalYPosition = (dependency.getHeight() /2);
if (mStartHeight == 0)
mStartHeight = child.getHeight();
if (mStartXPosition == 0)
mStartXPosition = (int) (child.getX() + (child.getWidth() / 2));
if (mFinalXPosition == 0)
mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);
if (mStartToolbarPosition == 0)
mStartToolbarPosition = dependency.getY();
if (mChangeBehaviorPoint == 0) {
mChangeBehaviorPoint = (child.getHeight() - mCustomFinalHeight) / (2f * (mStartYPosition - mFinalYPosition));
}
}
private void movePin(double x, double y, double z) {
// todo this is currently hard coded for 2D setups
final ImageView ImageView_BitmapView = findViewById(R.id.map);
final ImageView ImageView_Pin = findViewById(R.id.pin);
ImageView_Pin.setVisibility(View.VISIBLE);
// 0,0 point is 82.4427% down the image and 2.336% from the left of the image
float x_image_offset = (ImageView_BitmapView.getWidth() * 0.02336f);
float y_image_offset = (ImageView_BitmapView.getHeight() * 0.824427f);
x_image_offset = ImageView_BitmapView.getX() + x_image_offset;
y_image_offset = ImageView_BitmapView.getY() + y_image_offset;
float pin_width = ImageView_Pin.getWidth();
float pin_height = ImageView_Pin.getHeight();
float x_pin_offset = (pin_width / 2.0f);
float y_pin_offset = (pin_height) - (5.0f / 72.0f * pin_height); // There are a few pixels at the bottom of the pin
// Account for the fact that the Pin is pointing to the lower middle of the image view
float pinOriginX = x_image_offset - x_pin_offset;
float pinOriginY = y_image_offset - y_pin_offset;
//ImageView_Pin.setX(pinOriginX);
//ImageView_Pin.setY(pinOriginY);
float floorWidth = ImageView_BitmapView.getWidth() * (1772.0f / 3982.0f);
float floorHeight = ImageView_BitmapView.getHeight() * (1488.0f / 2096.0f);
float scaledX = (float) (x / 8370.0f * floorWidth);
float scaledY = (float) (y / 7000.0f * floorHeight);
ImageView_Pin.setX(pinOriginX + scaledX);
ImageView_Pin.setY(pinOriginY - scaledY);
}
/**
* 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);
}
/**
* Get the scan rectangle.
* @return The rectangle.
*/
public static Rect getScanRect(ImageView scanSegment) {
int startX = (int) scanSegment.getX();
int startY = (int) scanSegment.getY();
int width = scanSegment.getWidth();
int length = scanSegment.getHeight();
return new Rect(startX, startY, startX + width, startY + length);
}
public void saveIconsToPref() {
for(ImageView view : viewList) {
IconHolder holder = (IconHolder) view.getTag();
addToPrefPackageList(holder.packageName);
holder.x_pos = view.getX();
holder.y_pos = view.getY();
}
}