【发布时间】:2019-02-12 01:54:39
【问题描述】:
我正在为退出确认创建一个自定义弹出窗口。为此,我使用RelativeLayout 和layout_width="match_parent" 和layout_height="match_parent" 属性。
如何使WebView 区域无法滚动和点击?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/content_main"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/app_bar_main">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/banner_main">
<WebView
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="400dp" />
</ScrollView>
<RelativeLayout
android:id="@+id/exit_popup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:orientation="vertical"
android:visibility="gone"
android:background="#80111111"
android:padding="0dp">
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:background="#fff"
app:cardUseCompatPadding="true"
app:cardElevation="10dp"
app:cardCornerRadius="0dp"
ads:contentPadding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:padding="5dp"
android:text="ARE YOU SURE TO EXIT?"
android:textColor="#000"
android:textSize="18dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="7dp">
<Button
android:id="@+id/button_cancel"
android:drawableLeft="@drawable/ic_back"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="18dp"
android:layout_marginRight="7dp"
android:layout_weight="1"
android:text="Nope"
android:textColor="#fff"
android:textSize="14sp" />
<Button
android:id="@+id/button_exit"
android:drawableRight="@drawable/ic_arrow_forward"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="18dp"
android:layout_weight="1"
android:text="Yes"
android:textColor="#fff"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</RelativeLayout>
【问题讨论】:
-
为什么不直接使用不可取消的 AlertDialog?
-
@TheWanderer 我想用布局创建更多自定义样式。
-
您可以使用 AlertDialogs 做到这一点。只需使用
setView()。 -
如果你想要那个。显示对话框时只需禁用
scrollview.setEnabled(false)。
标签: java android xml android-layout