我有一个透明的布局(见下文),我以编程方式膨胀并添加了一个现有的布局。这工作正常,但我仍然可以滚动并使用黑色0.3 alpha区域下方的按钮。
如何防止这种情况并构建“真正的”模态布局?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:alpha="0.3"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="200dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_alignParentBottom="true"
android:orientation="vertical">
...
</RelativeLayout>
</RelativeLayout>
答案 0 :(得分:0)
您需要让视图拦截触摸和点击事件。
将android:clickable="true"
添加到您的黑色相对布局中。
如果它不起作用,您需要将focusableInTouchMode
添加到true,将focusable
添加为true。