Search code examples
androidxmlandroid-layout

How to stop click event through a semi transparent background?


I am trying to set a semi-transparent view over another view when user click on a certain button. And at the same time I want my background view not to be clickable. So basically I am setting alpha as 0.9 to my foreground view.

Code

    <RelativeLayout
    android:id="@+id/rl_fg_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#231564"
    android:alpha="0.9"
    android:visibility="visible"/>

and below this view there is a listview. So when user click on a button this view will pop up but at the same time background view (i.e. ListView) also clickable at the same time.


Solution

  • Set android:clickable="true" in xml to your foreground view.