有没有办法在布局 xml 中而不是在代码中定义 webview。
如果是这样怎么办?还是建议将其编码到 Activity 中?
最佳答案
是的,如上所述使用 WebView 标签:
<WebView android:id="@+id/webview"
android:layout_width="fill_parent" android:layout_height="50dip"/>
可在此处找到示例应用程序: http://www.androiddom.com/2011/04/creating-android-calculator-tutorial.html
作者创建了一个使用 main.xml 布局中指定的 WebView 的计算器。
关于Android Webview - XML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11779579/