如何为特定应用添加特定 CSS

How to add a particular CSS for particular app

我有一个实时网站,我想用 WebView 在我的应用程序中显示它。但我也想在我的网站中添加一个 css 文件,该文件仅在该特定应用程序加载该网站时才有效。否则 css 将不起作用。 这可能吗?如果可能的话请谁能告诉我该怎么做?

将网站的 index.htmlcss file 放入 Android 项目的 assets 文件夹中。修改您的 index.html,以便通过向其添加 link 来加载 css file

然后在加载 WebView 时,只需加载 assets 文件夹中的 index.html 即可。像这样:webView.loadUrl("file:///android_asset/index.html")