clickable
seems useful when you want your view to consume clicks so that they don’t go to the top views.
For example, I have a FrameLayout
that I show above the base RelativeLayout
at a specific time. When the user clicks on the main EditText
, the focus moves to EditText
. Really annoying when FrameLayout
is still displayed. Now the user does not know why the keyboard just popped up or where they type.
When I set clickable="true"
in FrameLayout
, users could no longer accidentally name the underlying EditText
fields.
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" ...> <EditText> <EditText> <EditText> <FrameLayout android:id="@+id/sometimes_visible_view" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#80808080" android:clickable="true" android:visibility="gone" android:focusable="true" ...> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" ...> <View> <View> </LinearLayout> </FrameLayout> </RelativeLayout>
source share