Android 布局 - 禁用不必要的区域

我正在为退出确认创建一个自定义弹出窗口。为此,我使用RelativeLayout带有属性的 alayout_width="match_parent"layout_height="match_parent".

如何使该WebView区域禁用滚动和单击?

http://img.mukewang.com/62a947340001bda707181270.jpg

<?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"


                </LinearLayout>

            </LinearLayout>

        </android.support.v7.widget.CardView>

    </RelativeLayout>

</RelativeLayout>


慕村225694
浏览 99回答 2
2回答

海绵宝宝撒

通过在背景布局上添加 onClick 侦听器解决了问题。<RelativeLayout&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/exit_popup"&nbsp; &nbsp; &nbsp; &nbsp; android:onClick="nullMethod"public void nullMethod(View view) {}

BIG阳

这是我在 webview 中禁用所有滚动的代码:disable scroll on touchwebview.setOnTouchListener(new View.OnTouchListener() {&nbsp; @Override&nbsp; public boolean onTouch(View v, MotionEvent event) {&nbsp; &nbsp; return (event.getAction() == MotionEvent.ACTION_MOVE);&nbsp; }});要仅隐藏滚动条,请在执行弹出窗口时添加代码。&nbsp;web = (WebView) findViewById(R.id. web);&nbsp;&nbsp;web.setVerticalScrollBarEnabled(false);&nbsp;web.setHorizontalScrollBarEnabled(false);您还可以尝试使用垂直滚动的滚动视图包装您的 webview,并禁用 webview 上的所有滚动:web.setScrollContainer(false);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java