我的網絡視圖內有一個圖像。圖像太大了,我啓用了滾動條,但問題是我想設置默認視圖(在滾動或縮放之前首先查看圖像)到圖像的特定部分。任何想法 ?Android webView專注於圖像的特定部分
WebView callUsView2= (WebView) rootView.findViewById(R.id.callUsView2);
WebSettings callUsView2Setting = callUsView2.getSettings();
callUsView2Setting.setBuiltInZoomControls(true);
callUsView2Setting.setDisplayZoomControls(true);
callUsView2.setVerticalScrollBarEnabled(true);
callUsView2.setHorizontalScrollBarEnabled(true);
callUsView2.loadUrl("file:///android_asset/map.png");
結果>
我想要什麼>
答案>>
callUsView2.setWebChromeClient(new WebChromeClient(){
@Override
public void onProgressChanged(WebView view, int progress) {
if (view.getProgress()==100) {
// I save Y w/in Bundle so orientation changes [in addition to
// initial loads] will reposition to last location
jumpToY(1000 , 1800);
}
}
private void jumpToY (final int xLocation , final int yLocation) {
callUsView2.postDelayed(new Runnable() {
@Override
public void run() {
callUsView2.scrollTo(xLocation, yLocation);
}
}, 300);
}
});
也許做你的放大,顯示圖像之前?隱藏您的WebView並準備好揭示它。 –
對不起,我不明白你的意思!? –
如果我正確地理解了你,你希望在用戶看到地圖之前進行縮放。真的嗎? –