29 android android-ui android-webview android-resources
我正在尝试将webview的背景设置为Android中的可绘制图像资源.
从sdk看起来这样的东西可以工作,但事实并非如此.
WebView web = (WebView) findViewById(R.id.webView);
web.setBackgroundResource(R.drawable.backgroundmain);
web.loadData(profile, "text/html", "UTF-8");
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
小智 65
一如既往,当你提出这个问题时,你往往会把这些事情搞清楚.为了其他人的利益,我正在使用的布局LinearLayout可以采用可以是颜色或资源的背景参数.
所以在我的视图.xml文件中我只添加了一个
android:background="@+drawable/backgroundmain"
Run Code Online (Sandbox Code Playgroud)
并使用
web.setBackgroundColor(0);
Run Code Online (Sandbox Code Playgroud)
使webview透明以查看背后的背景图像.
小智 25
如果你做这样的事情,它将完美地工作:
webView.setBackgroundColor(Color.TRANSPARENT);
webView.setBackgroundResource(R.drawable.your_image);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28697 次 |
| 最近记录: |