通过Android上的Google视图浏览PhotosPheres

时间:2015-02-09 10:38:29

标签: android webview photosphere

我正在尝试创建一个可以显示我的PhotosPhere张照片的应用。问题是当我尝试从WebView加载图像时,当我滚动照片时,它似乎不会滚动,而是跳转到我滚动的点。我在这里阅读使用getScrollX,Y函数但我无法使它们工作,因为它们在我已经导入它们时似乎未被识别(import android.view)。知道我怎么能让它正常工作吗?

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import android.view.accessibility.AccessibilityEvent;

public class BrowserView extends Activity {

    String web;
    WebView Browser;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);
        Browser = (WebView) findViewById(R.id.wbView);
        // Use browser in application
        Browser.setWebViewClient(new ourViewClient());
        // Enable JavaScript
        Browser.getSettings().setJavaScriptEnabled(true);
        // Zoom Out
        Browser.getSettings().setLoadWithOverviewMode(true);
        Browser.getSettings().setUseWideViewPort(true);

        Bundle gotBasket = getIntent().getExtras();
        web = gotBasket.getString("key");
        Browser.loadUrl(web);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {

        if (event.getAction() == MotionEvent.ACTION_DOWN) {

            int temp_ScrollY = getScrollY();
            scrollTo(getScrollX(), getScrollY() + 1);
            scrollTo(getScrollX(), temp_ScrollY);
        }

        return super.onTouchEvent(event);
    }



    // Client
    private class ourViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }
}

0 个答案:

没有答案