使用WebView在Android中嵌套html网页
来源:互联网 发布:算法导论中文 pdf 编辑:程序博客网 时间:2024/06/05 16:22
对于一些html学习较好的朋友,开发Android项目的时候把html网页嵌套手机中,写起来比android布局要方便很多,那么下面就和大家分享一下怎么把html页面嵌套到android布局中
页面:
重点使用的android控件为WebView
第一步: 在你的布局中实例一个WebView,并且取一个id
<WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/wv_produce" > </WebView>第二步: 把你编写的html文件和相应的文件夹,新建一个和res同级的文件夹assets,必须以assets命名
第三步: 实例一个相对应的java文件
super.onCreate(savedInstanceState); setContentView(R.layout.activity_produce); wv_produce = (WebView) findViewById(R.id.wv_produce); //这里的文件路径是死定的,把html文件名改掉就可以了 wv_produce.loadUrl("file:///android_asset/produce.html"); //支持App内部JavaScript交互 wv_produce.getSettings().setJavaScriptEnabled(true); //自适应手机屏幕 wv_produce.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); wv_produce.getSettings().setLoadWithOverviewMode(true); //设置是否出现缩放工具 wv_produce.getSettings().setBuiltInZoomControls(true); //设置可以支持缩放 wv_produce.getSettings().setSupportZoom(true); //扩大比例的缩放 wv_produce.getSettings().setUseWideViewPort(true); //设置编码为utf-8 wv_produce.getSettings().setDefaultTextEncodingName("utf-8");
对了,别忘记配置哈
阅读全文
0 0
- 使用WebView在Android中嵌套html网页
- Android WebView怎么样嵌套Html
- Android WebView嵌套Html 之一
- Android:在WebView中获取网页源码
- Android:在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android: 在WebView中获取网页源码
- Android在网页下(WebView中运用HTML)点击按钮打开本地手机应用程序
- Android中WebView使用1,加载网页
- ipython notebook实用教程
- Could not find a storyboard named 'Main' in bundle NSBundle?
- 【好久不见】捡起mysql的存储过程
- 根据域名动态获取IP地址(iOS)
- 打造云上代码交付链_CodePipeline实践分享
- 使用WebView在Android中嵌套html网页
- Error:Failed to complete Gradle execution.
- JAVA位运算
- 深入理解分布式事务
- MIUI8不用root更换字体的方法
- 解决scrollview嵌套listview ,listview异常,数据不显示,高度异常,布局异常
- Activity生命周期、启动模式、缓存
- Eclipse复制粘贴很卡解决方法
- NodeJs学习笔记(二)————NodeJs的安装