ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


[°³¹ß Tip] webview ½ºÅ©·Ñ
8³â Àü
Ãâó: http://stackoverflow.com/questions/2238938/how-to-programmatically-scroll-android-webview

It turns out that the window.scrollTo() DOES work, you just can't add your own method named scrollTo(). For some reason my own scrollTo() method was being invoked when I called window.scrollTo().

So, in summary, to scroll a WebView to a particular DOM element, write a JavaScript function to do the scrolling:

function scrollToElement(id) {
    var elem = document.getElementById(id);
    var x = 0;
    var y = 0;

    while (elem != null) {
        x += elem.offsetLeft;
        y += elem.offsetTop;
        elem = elem.offsetParent;
    }
    window.scrollTo(x, y);
}

and then from your Android app (Java code), tell your WebView to load a URL:

webView.loadUrl("javascript:scrollToElement('" + elemId + "')");

There are some issues with this approach, such as the scroll will not be nicely animated, but the general mechanism works.

The DOM window object does report the current scroll position of the WebView correctly (see window.pageXOffset, window.pageYOffset or window.scrollX, window.scrollY). If you just want to know the current scroll position of the WebView, write some JavaScript to call your Java code and pass along the X/Y offsets.

Ȥ½Ã À¥ºä ¾²½Ã´Ù°¡ ¿·¿¡ ½ºÅ©·Ñ Èò»ö °ø°£ÀÌ °Å½½¸®½Ã´Â ºÐµéÀº
webview.setVerticalScrollbarOverlay(true);
Ãß°¡ÇØÁÖ½Ã¸é µÇ°Ù½À´Ï´ç

ÃßõÃßõ : 299 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
67
¹Ù·ÎÇ®¾î(¼öÇÐ ¹®Á¦ ÁúÀÇÀÀ´ä SNS) ¿¡ »ç¿ëµÈ ¿ÀǼҽº ¶óÀ̺귯¸® [Android]
66
¿ÀǼҽº ¶óÀ̺귯¸® ¸ðÀ½ [Android]
65
´Ü¸»±â ¹öÀü Á¤º¸ [Android]
64
Android webview °³¹ß½Ã ¾Ë¾ÆµÖ¾ß ÇÒ °Íµé [Android]
63
[¾Èµå·ÎÀ̵å] ¾Û ³»¿¡¼­ ·±Å¸ÀÓ ±ÇÇÑÀ» ¿äûÇÏ´Â ¹æ¹ý
62
webview µ¿¿µ»ó Àç»ý [Android]
61
android studio DefaultHttpClient, HttpClient import ¿¡·¯
60
[Android] ANR À̶õ?
59
¾Èµå·ÎÀÌµå ¿ÀǼҽº
58
Android] AlarmManager ÀÏÁ¤½Ã°£ À̺¥Æ® ½ÇÇà
57
[Android] Webview url ¼û±â±â
56
[Android] webview ssl ¹®Á¦
55
[Android] Webview 404 ¿¡·¯ ó¸®
54
[Android] Webview ¸Þ¼Òµå
53
[¾Èµå·ÎÀ̵å] À¥ºä(WebView ¿¡¼­ ÀÚ¹Ù½ºÅ©¸³Æ® alert ¶ç¿ì±â
52
(Android) WebView _blank ó¸®
51
webvew ¿¡¼­ ºê¶ó¿ìÀú·Î ¸µÅ©(_blank)
50
[Android]¾Èµå·ÎÀ̵å Intent »ç¿ë¹ý
49
¾Èµå·ÎÀÌµå ¹Ìµð¾î Ç÷¹À̾î (MediaPlayer) ¿¹Á¦
48
[Android] BroadcastReceiver »ç¿ëÇϱâ
47
Media Player¸¦ ÀÌ¿ëÇÑ À½¾Ç Àç»ý
46
[°³¹ß Tip] Activity³» ¹è°æÀ» Åõ¸íÇÏ°Ô Çϱâ
45
Android VideoView Example
44
[°³¹ß Tip] WebView ·Îµù½Ã ŸÀÌƲ¹Ù¿¡ ÁøÇàÁß ¾ÆÀÌÄÜ º¸ÀÌ°Ô Çϱâ
[°³¹ß Tip] webview ½ºÅ©·Ñ
42
[°³¹ß Tip] WebView ¿¡¼­ ÀÚ¹Ù ½ºÅ©¸³Æ® »ç¿ë¿¹
41
[°³¹ß Tip] WebView À¥ÆäÀÌÁö ·Îµù½Ã°£ ±¸Çϱâ
40
[°³¹ß Tip] WebView ÆäÀÌÁö°¡ ·ÎµùµÇ¾úÀ»¶§ ó¸®
39
[°³¹ß Tip] WebView¿¡ »õâ(href)ÀÌ ¶ã¶§ À¥ºê¶ó¿ìÁ®°¡ ¾Æ´Ñ ÇöÀç WebView·Î Ãâ·ÂÇϱâ
38
[°³¹ß Tip] WebView¿¡¼­ ¸ÖƼ ÅÍÄ¡ °¡´ÉÇÏ°Ô Çϱâ
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.