【问题标题】:how to disable background activity from transparent overlay fragment如何从透明覆盖片段中禁用背景活动
【发布时间】:2015-10-14 06:20:06
【问题描述】:

我已经创建了关于活动的透明片段叠加教程,我想禁用透明片段下方显示的背景活动的触摸事件。所以用户不能从活动中触摸任何东西,只能使用片段帮助教程。

提前谢谢你

【问题讨论】:

    标签: android overlay android-fragmentactivity


    【解决方案1】:

    如果您在设置为全屏的活动上使用片段,即match_parent。然后在片段根布局中,您可以设置属性android:clickable="true" 来消费点击事件。默认情况下,RelativeLayout、LinearLayout 等布局不消耗点击事件。其他视图(例如 Button 和 TextView)默认开启。

    在您的叠加片段中。

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

    【讨论】:

    • 非常感谢...您的解决方案对我有用...所有视图的触摸事件都被禁用,除了导航抽屉...您能帮我解决这个问题吗...??@Modge
    • 确保布局在您的工具栏下方并且应该没问题
    • 我不确定那里,也许你可能不得不自己使用没有片段的布局
    【解决方案2】:

    或者只是通过 id 找到片段的父视图...并在其上设置 onClick 侦听器.. 完成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-05
      • 2019-10-29
      • 1970-01-01
      • 2013-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多