2012-06-20 55 views
0

好吧,我有一個swf文件從sdcard加載到webview中。我想知道是否有人知道在頁面加載後是否可以設置視圖的「縮放」和位置? 那麼我怎樣才能將視圖集中在swf文件上,而用戶不必放大並滾動文章的頂部。謝謝。加載swf文件時很熱設置web查看區域

回答

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("@[email protected]", "file:///android_asset/20051210-w50s.flv"); 
     webView.loadDataWithBaseURL("file:///android_asset/FLVPlayer.swf", htmlPre+htmlCode+htmlPost, "text/html", "UTF-8", null); 
    } 
+0

我會嘗試稍後today..thanks! –