图片打标签之获取图片在ImageView中的坐标

2022-06-25 11:03:24 浏览数 (1)

android matrix 最全方法详解与进阶(完整篇)

代码语言:javascript复制
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);

                }
            }

0 人点赞