Я создаю собственное всплывающее окно для подтверждения выхода. Для этого я использую 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>
@TheWanderer Я хочу создать более индивидуальный стиль с макетом.
Вы можете сделать это с помощью AlertDialogs. Просто используйте setView().
Если ты хочешь этого. Просто отключите scrollview.setEnabled(false), когда появится диалоговое окно.




Вот мой код для отключения всей прокрутки в веб-просмотре:
disable scroll on touch
webview.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});
Чтобы скрыть только полосы прокрутки, добавьте код во время выполнения всплывающего окна.
web = (WebView) findViewById(R.id. web);
web.setVerticalScrollBarEnabled(false);
web.setHorizontalScrollBarEnabled(false);
Вы также можете попытаться обернуть свой веб-просмотр вертикальной прокруткой прокрутки и отключить всю прокрутку в веб-просмотре:
web.setScrollContainer(false);
Проблема решена путем добавления прослушивателя onClick в фоновом режиме.
<RelativeLayout
android:id = "@+id/exit_popup"
android:onClick = "nullMethod"
public void nullMethod(View view) {}
Почему бы просто не использовать неотменяемый диалог AlertDialog?