-
Kotlin) 웹뷰에서 popup 실행시키기Programing Language/Android Studio(Java&Kotlin) 2021. 6. 21. 15:35728x90반응형
//스크롤이 설정 - 스크롤이 bar가 보이지 않도록 해준다. webview.isVerticalScrollBarEnabled = false webview.isHorizontalScrollBarEnabled = false webSettings = ManiaWebView.settings // 웹뷰 멀티 터치 가능하게 (줌기능) //webSettings.setBuiltInZoomControls(true); // 줌 아이콘 사용 webSettings?.setSupportZoom(true) webSettings?.displayZoomControls = true webSettings?.setJavaScriptEnabled(true) // 자바스크립트 사용이 가능해야 함 webSettings?.domStorageEnabled = true // localStorage 사용을 위해 webSettings?.setSupportMultipleWindows(true); webSettings?.javaScriptCanOpenWindowsAutomatically = true; webview.webChromeClient = object : WebChromeClient() { override fun onCreateWindow(view: WebView?, isDialog: Boolean, isUserGesture: Boolean, resultMsg: Message?): Boolean { val newWebView = WebView(this@MainActivity).apply { webViewClient = WebViewClient() settings.javaScriptEnabled = true settings.userAgentString = "Mozilla/5.0 AppleWebKit/535.19 Chrome/56.0.0 Mobile Safari/535.19"; } val dialog = Dialog(this@MainActivity).apply { setContentView(newWebView) window!!.attributes.width = ViewGroup.LayoutParams.MATCH_PARENT window!!.attributes.height = ViewGroup.LayoutParams.MATCH_PARENT show() } newWebView.webChromeClient = object : WebChromeClient() { override fun onCloseWindow(window: WebView?) { dialog.dismiss() } } (resultMsg?.obj as WebView.WebViewTransport).webView = newWebView resultMsg.sendToTarget() return true } }
728x90반응형'Programing Language > Android Studio(Java&Kotlin)' 카테고리의 다른 글
Android) 키스토어 분실시 재발급 요청하는 방법 (0) 2021.06.29 Android) 웹뷰에서 Kotlin Javascript 통신하기 (0) 2021.06.21 Android) imageview레이아웃 Wallpaper로 설정하기 [Kotlin] (0) 2021.04.23 Android)네트워크 상태 확인하기 (0) 2021.04.12 Android) CLEARTEXT communication to XXXX not permitted by network security policy (0) 2020.12.20