Giúp em cái này với ạ, e muốn vẽ mũi tên nẵm chính giữa 2 views, nhưng mà nó cứ bị lệch, code của e đây ạ.
val mImageView = findViewById<ImageView>(R.id.image_view_1)
val mButton = findViewById<Button>(R.id.button_1)
val tv1 = findViewById<View>(R.id.textView)
val tv2 = findViewById<View>(R.id.textView2)
val currentDisplay = windowManager.currentWindowMetrics
val dw = currentDisplay.bounds.width()
val dh = currentDisplay.bounds.height()
val mBitmap = Bitmap.createBitmap(dw, dh, Bitmap.Config.ARGB_8888)
val mCanvas = Canvas(mBitmap)
mImageView.setImageBitmap(mBitmap)
mButton.setOnClickListener {
val mPaint = Paint()
mPaint.color = Color.GREEN
mPaint.style = Paint.Style.STROKE
mPaint.strokeWidth = 10F
mPaint.isAntiAlias = true
val mStartX = tv1.bottom.toFloat()
val mStartY = tv1.left.toFloat()
val mStopX = tv2.top.toFloat()
val mStopY = tv2.right.toFloat()
mCanvas.drawLine(mStartX, mStartY, mStopX, mStopY, mPaint)
mImageView.setImageBitmap(mBitmap)
}
e muốn kết quả như vầy ạ.
còn đây là hình code chạy