18

in the following UI I have this below drabable overlaying the entire screen. The LinearLayout is transparent and allows controls below it to be clickable or touchable. Basically I can scroll a list below this LinearLayout as well as click controls. How do I disable that?

See attached example.enter image description here

Thank you

<RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rlExtNavbar" 
    android:orientation="vertical"
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:gravity="fill_vertical"
    android:layout_gravity="fill_vertical"
    android:background="@color/transparent" xmlns:tools="http://schemas.android.com/tools" tools:ignore="Overdraw">
    <RelativeLayout
        android:id="@+id/expandedNavbarLayout" 
        android:orientation="vertical"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" >
    </RelativeLayout>
    <LinearLayout
        android:id="@+id/transparentLayout" 
        android:orientation="vertical"
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"
        android:layout_below="@id/expandedNavbarLayout"
        android:focusableInTouchMode="false"
        android:focusable="false"
        android:background="@color/fulltransparent">
    </LinearLayout>

</RelativeLayout>
dropsOfJupiter
  • 6,763
  • 12
  • 47
  • 59
  • Possible duplicate of [How to disable behind view click event Framelayout](https://stackoverflow.com/questions/16377593/how-to-disable-behind-view-click-event-framelayout) – Mehdi Dehghani May 15 '18 at 06:53

3 Answers3

114

Just setting the android:clickable="true" property for the LinearLayout in the XML will prevent the clicks going through -- no need for a click listener.

Theo
  • 5,963
  • 3
  • 38
  • 56
2

Assigned a click to Linear Layout and that solved it. Honestly it should not be working like this to begin with but that solved the problem. The click is empty.

dropsOfJupiter
  • 6,763
  • 12
  • 47
  • 59
0

What worked for me was to put the LinearLayout before the inner RelativeLayout in the xml.

Rooster242
  • 911
  • 3
  • 10
  • 19