通过半透明布局隐藏片段

问题描述 投票:-2回答:2

我的要求是 - 我在一个具有UI的片段中创建了一个布局。我必须通过半透明的图像或布局或其他东西隐藏该UI,以便实际的UI变得不可点击。用户界面应该仍然可见,只是不可点击。我怎样才能做到这一点?

java android user-interface clickable
2个回答
1
投票

这可以简单地通过RelativeLayout来完成。

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
 <LinearLayout
   android:layout_width="match_parent"
   android:layout_height="match_parent">
   // Your fragment Content goes hre

  </LinearLayout>
   <RelativeLayout
    android:id="@+id/rel_Translucent"
    android:layout_width="match_parent"
    android:background="#33000000"
    android:clickable="true"
    android:visibility="gone"
    android:layout_height="match_parent">


    </RelativeLayout>
   </RelativeLayout>

只要你想要半透明叠加,就把rel_Translucent设置为VISIBLE


0
投票

您无需添加额外视图即可实现所需。您可以通过将enabled设置为false来禁用单击事件。

您可以在下面的答案中使用Parag Chauhan提到的功能:

How to disable all click events of a layout?

希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.