0

好的,所以我有一个从 sdcard 加载到 webview 中的 swf 文件。我想知道是否有人知道加载页面后是否可以设置视图的“缩放”和位置?那么我怎么能在没有用户放大和滚动文章顶部的情况下将视图焦点放在 swf 文件上。谢谢。

4

1 回答 1

2

你可以使用这个代码

public class FLVplayerActivity extends Activity {
    WebView webView;
    String htmlPre = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"></head><body style='margin:0; pading:0; background-color: black;'>";  
    String htmlCode = 
            " <embed style='width:100%; height:100%' src='http://www.platipus.nl/flvplayer/download/1.0/FLVPlayer.swf?fullscreen=true&video=http://www.platipus.nl/flvplayer/download/pl-600.flv&autoplay=true' " +
            "  autoplay='true' " +
            "  quality='high' bgcolor='#000000' " +
            "  name='VideoPlayer' align='middle'" + // width='640' height='480' 
            "  allowScriptAccess='*' allowFullScreen='true'" +
            "  type='application/x-shockwave-flash' " +
            "  pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
            "";
    String htmlPost = "</body></html>";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main); 

        webView = (WebView)findViewById(R.id.webview);

        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setPluginsEnabled(true);

            webView.getSettings().setSupportZoom(false);
            webView.getSettings().setAppCacheEnabled(false);
            webView.getSettings().setAllowContentAccess(true);
            webView.getSettings().setCacheMode(webView.getSettings().LOAD_NO_CACHE);

        webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); //thanks Patrick!

        //webView.loadUrl("file:///android_asset/index.html");
        //htmlCode = htmlCode.replaceAll("@VIDEO@", "file:///android_asset/20051210-w50s.flv");
        webView.loadDataWithBaseURL("file:///android_asset/FLVPlayer.swf", htmlPre+htmlCode+htmlPost, "text/html", "UTF-8", null);  
    }
于 2012-06-20T05:23:37.827 回答