0
  <base href="http://www.myurl.com/">
        <link href="templates/default/css/mycss.css?1" rel="stylesheet" type="text/css" />

我正在尝试使用 android webview 加载一个 url。页面已加载,但没有 css。有一种方法(用于相对路径)。有没有办法直接用css加载页面而不缓存并用loadDataWithBaseURL打开它?

4

1 回答 1

0

尝试这个...

    Description = (WebView)findViewById(R.id.webView1);
    Description.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
    Description.getSettings().setJavaScriptEnabled(true);
    Description.getSettings().setBuiltInZoomControls(true);
    //PodcastDescription.setTextSize(20.f);
    //PodcastDescription.setTypeface(tf);

    Bundle mybundle = getIntent().getExtras();
    Integer NewsNumber = mybundle.getInt("number");


    String CurrentDescription = Entertainment.Description[NewsNumber];




    Description.loadDataWithBaseURL (null, "<html><head><style>@font-face{font-family:'MeeraRegular'; src: url('file:///android_asset/fonts/Meera.ttf');}body{font-family:'MeeraRegular'; font-size:20px; } </style></head><body>"+CurrentDescription+"</body></html>", "text/html", "UTF-8",
    null); 
于 2012-04-26T10:34:16.733 回答