Это в значительной степени самоэкспланирующе. В настоящее время я использую SurfaceView и накладываю его на настоящий экран. Я изо всех сил пытаюсь сделать прикосновение, когда наложение активно. < /P>
fun initialize() {
// Create the surface view
surfaceView = SurfaceView(context).apply {
setZOrderMediaOverlay(true)
holder.setFormat(PixelFormat.TRANSLUCENT)
holder.addCallback(this@AutoTranslationSurfaceRenderer)
// Set alpha on the view itself for visual transparency
alpha = 0.8f
// Set up touch listener to pass all events through
setOnTouchListener { _, event ->
// Return false to indicate we didn't handle the event
// This allows it to pass through to views below
false
}
isFocusable = false
isFocusableInTouchMode = false
}
// Add the surface view to the window with enhanced flags for cutout support
val params = WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS or
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSLUCENT
).apply {
gravity = Gravity.TOP or Gravity.START
}
try {
windowManager.addView(surfaceView, params)
surfaceHolder = surfaceView?.holder
// Add a parent view touch listener to ensure touch events pass through
surfaceView?.parent?.requestDisallowInterceptTouchEvent(true)
} catch (e: Exception) {
Log.e(TAG, "Error adding surface view: ${e.message}")
}
}
Я ожидаю, что смогу коснуться и прокрутить реальный экран, когда наложение активно.
Это в значительной степени самоэкспланирующе. В настоящее время я использую SurfaceView и накладываю его на настоящий экран. Я изо всех сил пытаюсь сделать прикосновение, когда наложение активно. < /P> [code] fun initialize() { // Create the surface view surfaceView = SurfaceView(context).apply { setZOrderMediaOverlay(true) holder.setFormat(PixelFormat.TRANSLUCENT) holder.addCallback(this@AutoTranslationSurfaceRenderer) // Set alpha on the view itself for visual transparency alpha = 0.8f
// Set up touch listener to pass all events through setOnTouchListener { _, event -> // Return false to indicate we didn't handle the event // This allows it to pass through to views below false }
// Add the surface view to the window with enhanced flags for cutout support val params = WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT ).apply { gravity = Gravity.TOP or Gravity.START }