Wie mache ich Touch Pass SurfaceView Overlay?Android

Forum für diejenigen, die für Android programmieren
Anonymous
 Wie mache ich Touch Pass SurfaceView Overlay?

Post by Anonymous »

Es ist ziemlich selbsterklärend. Derzeit verwende ich SurfaceView und überlagert es über den realen Bildschirm. Ich kämpfe darum, wie ich den Touch -Pass machen kann, wenn das Overlay aktiv ist. < /P>

Code: Select all

    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}")
}
}
Ich erwarte, den realen Bildschirm zu berühren und zu scrollen, wenn das Overlay aktiv ist.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post