Reputation: 5134
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.
Upvotes: 15
Views: 8273
Reputation: 121
Make the foreground clickable. Add these 2 properties in the semi transparent view xml, in parent Layout:
android:clickable="true"
android:focusable="true"
Example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f2354454"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<TextView .... />
</LinearLayout>
Upvotes: 0
Reputation: 658
Set android:clickable="true"
in xml to your foreground view.
Upvotes: 35
Reputation: 8468
If somebody needs to do this with a cardView widget, then try:
android:foreground="?android:selectableItemBackground"
android:clickable="true
Upvotes: 2
Reputation: 48
Try setting the attribute android:filterTouchesWhenObscured
to true
. That should work.
Upvotes: 1