In my app I have a fragment on top of the activity. The fragment is filling the whole screen. Part of the fragment is a transparent View and you can see the views under (that belong to the activity). Is there a way to transfer the touch events to the views that are under the transparent View of the fragment? Thanks!
            Asked
            
        
        
            Active
            
        
            Viewed 4.2k times
        
    56
            
            
        - 
                    3this should be standard behaviour I think as long as the transparent view (or it's parents) has no onclicklistener – Ivo Oct 30 '13 at 08:17
 
3 Answers
42
            In your overriden onTouchEvent method inside the fragment return false, it passes the touch event to the lower layer views.
        Vasily Kabunov
        
- 6,511
 - 13
 - 49
 - 53
 
        Maciej Boguta
        
- 1,354
 - 1
 - 12
 - 15
 
38
            
            
        simplest way :
form here: http://stackoverflow.com/a/34436589/3818437
Declare your fragment not clickable/focusable by using
android:clickable="false"
android:focusable="false"
or
v.setClickable(false)
v.setFocusable(false)
The click events should be dispatched to the fragment's parent now.
Note: To achieve this, you have to add a click to its direct parent. or set android:clickable="false" and android:focusable="false" to its direct parent to pass listener to further parent.
        mhdjazmati
        
- 4,152
 - 1
 - 26
 - 37
 
3
            
            
        You can use special flag in layoutParams.
(https://stackoverflow.com/a/53955777/2885859)
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
        Eugene Voronoy
        
- 1,384
 - 1
 - 14
 - 18