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

[°³¹ß 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);
Ãß°¡ÇØÁÖ½Ã¸é µÇ°Ù½À´Ï´ç

ÃßõÃßõ : 294 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
1,106
[Source] Åõ¸íÀ©µµ¿ì
1,105
[Source] WebView¸¦ ÀÌ¿ëÇؼ­, ÀÌÀü À¥ÆäÀÌÁö·Î À̵¿
1,104
[Source] ŸÀÌƲ¹ÙÀÇ ±ÛÀÚ»ö º¯°æ
1,103
[Source] Splash Screen
1,102
[Source] À̹ÌÁöÆÄÀÏ ´Ù¿î·Îµå
1,101
[Source] URLÀ» ÅëÇÑ À̹ÌÁö µå·ÎÀ×
1,100
[Source] PopupWindow »ç¿ë¿¹
1,099
[Source] WebView »ç¿ë¿¹ (loadUrl, loadData)
1,098
µ¿ÀûÀ¸·Î LinearLayout È­¸é¿¡ À̹ÌÁö Ãß°¡Çϱâ2
1,097
[Source] µ¿ÀûÀ¸·Î LinearLayout È­¸é¿¡ À̹ÌÁö Ãß°¡Çϱâ
1,096
[Source] Ä«¸Þ¶ó Á¦¾î
1,095
[Source] °£´ÜÇÑ MP3 Ç÷¹ÀÌ¾î ¿¹Á¦
1,094
[Source] Æù³» À½¾Ç ÆÄÀÏ ¸ñ·Ï Àоî¿À±â
1,093
[Source] MP3 ÆÄÀÏ ½ÇÇàÇϱâ
1,092
[android] ¹Ìµð¾î Ç÷¹À̾î·Î ¿Àµð¿À ºñµð¿À Àç»ýÇϱâ
1,091
µµ½º À©µµ ³×Æ®¿öÅ© ¸í·É¾î
1,090
[¾Èµå·ÎÀ̵å]ÆÄÀÏ ¿¬°á - Intent setDataAndType(Uri , MimeType)
1,089
±¸±Û °Ë»ö ÆÁ (±¸±Û¸µ, ±¸±Û °Ë»ö¹æ¹ý)
1,088
Windows 8 - Windows ±¸¼º ¿ä¼Ò ÀúÀå¼Ò¿¡¼­ ÆÄÀÏ ¼Õ»ó °Ë»ç
1,087
ÀÎÅÍ³Ý ÀͽºÇ÷η¯ 8 Á¤½Ä ´Ù¿î·Îµå
1,086
À©µµ¿ìÁî Windows 8, 8.1 ÀÇ ¹öÀüº° ei.cfg ÆÄÀÏ »ý¼ºÇÏ´Â ¹ý
1,085
Windows ¼³Ä¡ ÇÁ·Î±×·¥ ¹öÀü ±¸¼º ¹× Á¦Ç° ID ÆÄÀÏ(EI.cfg ¹× PID.txt)
1,084
ÀÌÁß ºÎÆà PC¿¡ ºÎÆà ¸Þ´º ¼³Á¤ ¶Ç´Â º¹±¸
1,083
ÆäÀ̽ººÏ µ¿¿µ»ó°ú À¯Æ©ºê µ¿¿µ»ó ´Ù¿î¹Þ´Â ¹æ¹ý
1,082
Å©·Ò(Chrome)¿¡¼­ DNS Áö¿ì±â - chrome dns flush
1,081
IE10, IE11 ¿¡¼­ Flash °¡ Á¤»óÀûÀ¸·Î ³ªÅ¸³ªÁö ¾ÊÀ» ¶§...
1,080
HTML5 ¾Ö´Ï¸ÞÀÌ¼Ç Á¦ÀÛ ÇÁ·Î±×·¥
1,079
¾µ¸¸ÇÑ jquery Ç÷¯±×ÀÎ
1,078
Windows ´ÜÃàÅ°
1,077
Internet ExplorerÀÇ ÀÛµ¿ÀÌ ÁßÁöµÇ¾ú½À´Ï´Ù-ÇØ°á ¹æ¹ý
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.