gpt4 book ai didi

android - 如何禁用透明覆盖 fragment 的背景 Activity

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:52:43 29 4
gpt4 key购买 nike

我已经创建了关于 Activity 的透明 fragment 叠加教程,我想禁用透明 fragment 下方显示的背景 Activity 的触摸事件。因此用户无法触摸 Activity 中的任何内容,只能使用 fragment 帮助教程。

提前致谢

最佳答案

如果您在设置为全屏的 Activity 上使用 fragment ,即 match_parent。然后在 fragment 根布局中,您可以设置一个属性 android:clickable="true" 来使用点击事件。默认情况下,诸如 RelativeLayout 、 LinearLayout 等布局不会消耗点击事件。其他 View (例如 Button 和 TextView)默认启用此功能。

在您的覆盖 fragment 中。

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

android:clickable="true">

</RelativeLayout>

关于android - 如何禁用透明覆盖 fragment 的背景 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33117980/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com