片段在另一个片段问题 [英] Fragment over another fragment issue

查看:138
本文介绍了片段在另一个片段问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我展示一个片段(这是全屏幕#77000000 背景)在另一个片段(我们称之为主),我的主要片段仍然反应点击(我们可以点击一个按钮,即使我们没有看到它)。

When I'm showing one fragment (which is full screen with #77000000 background) over another fragment (let's call it main), my main fragment still reacts to clicks (we can click a button even if we don't see it).

问题:怎么prevent点击第一个(主)片段

Question: how to prevent clicks on first (main) fragment?

修改

不幸的是,我不能隐瞒主要片段,因为我使用的是透明背景的第二个片段(这样,用户可以看到位于后面)。

Unfortunately, I can't just hide main fragment, because I'm using transparent background on second fragment (so, user can see what located behind).

推荐答案

设置点击上的第二个片段的,以真正的财产。该视图将捕获的事件,以便它不会被传递给主片段。因此,如果在第二片段的观点是一个布局,这将是code:

Set clickable property on the second fragment's view to true. The view will catch the event so that it will not be passed to the main fragment. So if the second fragment's view is a layout, this would be the code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true" />

这篇关于片段在另一个片段问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆