clickable
クリックを消費してトップビューの下のビューに移動しないようにするビューが必要な場合に便利なようです。
たとえば、特定の時間FrameLayout
に原資産の上に表示するものがあります。RelativeLayout
ユーザーが下にあるものをクリックするとEditText
、フォーカスがその下に移動しEditText
ます。FrameLayout
がまだ表示されていたときは本当に迷惑です。これで、ユーザーはキーボードがポップアップした理由や入力している場所がわかりません。
を設定clickable="true"
すると、ユーザーが誤って基になるフィールドをFrameLayout
クリックすることがなくなりました。EditText
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
...>
<EditText>
<EditText>
<EditText>
<!-- FrameLayout with grayed-out background. -->
<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>