我想我有這個。我張貼這個答案,因爲它可能有助於某人。
int HeightWv,contentHts;
@Override
public void onPageFinished(WebView view, String url)
{
System.err.println("Find Height->"+HeightWv);
Button b1 = (Button) findViewById(R.id.bt);
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(HeightWv==0){contentHts= 0;}
else if(HeightWv!=0){contentHts= HeightWv;}
HeightWv = wv.getHeight();
Log.e("1",""+ HeightWv);
HeightWv = HeightWv+contentHts;
Log.e("2",""+ HeightWv);
scrolpage();
}});
Button b2 = (Button) findViewById(R.id.bt2);
b2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(HeightWv==0){contentHts= 0;}
else if(HeightWv!=0){contentHts= HeightWv;}
HeightWv = wv.getHeight();
Log.e("3",""+ HeightWv);
HeightWv = contentHts-HeightWv;
Log.e("4",""+ HeightWv);
scrolpage();
}});
}
public void scrolpage(){
wv.scrollTo(0, HeightWv);
Log.e("scroll",""+ HeightWv);
}