2013-01-02 65 views
1

我有一個簡單的html文件,其中包含一個簡單的css文件,如果我使用chrome加載html文件顯示紙牌,則只顯示紙牌圖像。但是,如果我使用WebView加載相同的HTML文件,則沒有圖像。如果我只是設置背景顏色,那麼工作正常,所以HTML和CSS加載正確,工作,所以我假設問題是與圖像的網址。有什麼我失蹤?從Android WebView的CSS文件中加載背景圖像

感謝,

約翰

資產 game.html gamecss3.css 圖像0​​ssk.png

Java代碼

webView = (WebView) findViewById(R.id.webView1); 
webView.getSettings().setJavaScriptEnabled(true); 
webView.loadUrl("file:///android_asset/game.html"); 

CSS

body { 
    background: #aaa; 
} 
/* defines styles for each card */ 
.card { 
    width: 72px; 
    height: 96px; 
    margin: 20px; 
    background: url("images/ssK.png"); 
    /*background: #efefef; */ 
    position: absolute; 
    -webkit-transition: all 1s linear; 
} 

HTML 簡單的紙牌遊戲

卡牌遊戲

<section id="game"> 
    <div id="cards"> 
     <div id="card1" class="card"></div> 
    </div> <!-- #cards --> 
    </section> <!-- #game --> 
    <footer> 
    <p>This is an example of transitioning cards.</p> 
    </footer> 
</body> 
</html> 
+0

你回答了這個問題,我也想這個問題是在路徑圖像文件 – vodich

回答

0

是。圖片網址未找到。如果您有一個虛擬主機,請將其上傳到該虛擬主機,並分別更改您的CSS中的路徑。

0

您需要下載的圖像文件,然後使用webview.loadDataWithBaseUrl(...)啄..