2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

下層のレイアウトのボタンを押せてしまうときの対処法

Posted at

位置固定のfooterなどをつけているとき、クリックイベントを持っていないとスクロールで裏側に回ったボタンなどがfooterの上から押せてしまうことがある。

layout.xml
<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_alignParentBottom="true"
        android:clickable="true"
        android:background="@android:color/transparent"
        />

そんなときは、前面に回る要素(今回はfooterだった)にclickable="true"をつけてやれば、クリックしたときにこの要素がイベントを取ってくれるので、背後の要素がクリックイベントをとることがなくなる。

java側から何もしないonClickListenerをつけるという手でも同じなのかな。
とにかくclickイベントを持たしてあげればよさそう。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?