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中的坐标
最新推荐文章于 2023-06-21 11:28:56 发布
本文深入探讨了Android中Matrix类的使用方法,包括如何通过Matrix实现图像的缩放、旋转和平移等变换操作。文章提供了详细的代码示例,如使用Matrix与ImageView结合进行图像变换,以及如何获取和应用变换矩阵。
3万+

被折叠的 条评论
为什么被折叠?



