Pass touches to the view under

后端 未结 3 910
情歌与酒
情歌与酒 2020-12-10 00:35

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 (tha

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-10 00:56

    simplest way :

    from here : https://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: In order to achieve this, you have to add click to its direct parent. or set android:clickable="false" and android:focusable="false" to its direct parent to pass listener to further parent.

提交回复
热议问题