imageView = findViewById(R.id.imageview);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Drawable drawable = imageView.getDrawable();
Matrix matrix = imageView.getImageMatrix();
if (drawable != null) {
RectF rectf = new RectF();
rectf.set(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
matrix.mapRect(rectf); //最关键的一句
Log.i("lcf", "left " + rectf.left + " " + rectf.top + " " + rectf.right + " " + rectf.bottom);
}
}
图片打标签之获取图片在ImageView中的坐标
最新推荐文章于 2024-11-11 07:58:45 发布