亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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

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

慕村225694 2022-06-15 10:42:41
我正在為退出確認創建一個自定義彈出窗口。為此,我使用RelativeLayout帶有屬性的 alayout_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"                </LinearLayout>            </LinearLayout>        </android.support.v7.widget.CardView>    </RelativeLayout></RelativeLayout>
查看完整描述

2 回答

?
海綿寶寶撒

TA貢獻1809條經驗 獲得超8個贊

通過在背景布局上添加 onClick 偵聽器解決了問題。


<RelativeLayout

        android:id="@+id/exit_popup"

        android:onClick="nullMethod"


public void nullMethod(View view) {}


查看完整回答
反對 回復 2022-06-15
?
BIG陽

TA貢獻1859條經驗 獲得超6個贊

這是我在 webview 中禁用所有滾動的代碼:


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);

您還可以嘗試使用垂直滾動的滾動視圖包裝您的 webview,并禁用 webview 上的所有滾動:


web.setScrollContainer(false);


查看完整回答
反對 回復 2022-06-15
  • 2 回答
  • 0 關注
  • 115 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號