片段背后的一个无形的布局越来越点击: [英] An invisible layout behind the fragment is getting clicked:

查看:143
本文介绍了片段背后的一个无形的布局越来越点击:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了几个片段,我添加的第一个片段的方式如下:

I have created several fragments and I add the first fragment the following way:

mainFragment = (MainFragment) MainFragment.create();
    getSupportFragmentManager().beginTransaction()
    .setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right)
    .add(R.id.content, mainFragment, MAIN_FRAGMENT_TAG)
    .commit();

第二个片段添加这种方式:

The second fragment is added this way:

     getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right)
    //.hide(mainFragment)
    .add(R.id.content,VenueFragment.create(vid), "Venue Fragment")
    .addToBackStack(null)
    .commit();
    setDrawerIndicatorEnabled(false);

现在,你看是不是适用于本次交易的隐藏方法,以及 VenueFragment 打开,在这种情况下,问题是,虽然 VenueFragment 打开(这是一个全屏视图)这个片段的空段pressing调用的 MainFragment 点击观点通话。 如何prevent呢?

Now as you see the hide method is not applied for this transaction, and the VenueFragment is opened, the problem in this case is that while the VenueFragment opened (and it's a full screen view) pressing on empty section of this fragment invokes calls of the MainFragment clickable views. How can I prevent this?

如果我用的隐藏选项,则它不会发生,但由于某些原因,动画删除 MainFragment 正在上升,这使得一个奇怪的体验。

If I use the hide option then it's not happening but for some reason the animation for removing the MainFragment is going up and that makes a weird experience.

推荐答案

您需要让 VenueFragment 的ViewGroup C>可点击因此处理click事件,他们不传下(在z秩序感)其他片段

You need to make the root ViewGroup of VenueFragment clickable so it handles click events and they do not pass down (in the z-order sense) to the other Fragment.

这篇关于片段背后的一个无形的布局越来越点击:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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