WebView混合开发模式二(实现网页的放大,输小等功能)
来源:互联网 发布:c语言log2函数 编辑:程序博客网 时间:2024/05/18 03:42
package com.example.webview_backforward;import android.annotation.SuppressLint;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.webkit.WebView;import android.widget.Button;public class MainActivity extends Activity implements OnClickListener{ private Button buttonback,buttonforward,ZoonmIn,ZoomOut; private WebView webview; //private static String URL="http://www.sina.com"; private static String URL="http://www.hao123.com"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonback=(Button)findViewById(R.id.button1); buttonforward=(Button)findViewById(R.id.button2); ZoonmIn=(Button)findViewById(R.id.button3); ZoomOut=(Button)findViewById(R.id.button4); webview=(WebView)findViewById(R.id.webView1); buttonback.setOnClickListener(this); buttonforward.setOnClickListener(this); ZoonmIn.setOnClickListener(this); ZoomOut.setOnClickListener(this); webview.loadUrl(URL); // webview.clearView(); } @SuppressLint("NewApi") @Override public void onClick(View v) { switch(v.getId()){ case R.id.button1: if(webview.canGoBack()){ webview.goBack(); } break; case R.id.button2: if(webview.canGoForward()){ webview.goForward(); } break; case R.id.button3: if(webview.canZoomIn()){ webview.zoomIn(); } break; case R.id.button4: if(webview.canZoomOut()){ webview.zoomOut(); } break; } } }
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <Button android:id="@+id/button1" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="后退" /> <Button android:id="@+id/button2" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/button1" android:layout_toRightOf="@+id/button1" android:text="前进" /> <Button android:id="@+id/button3" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/button2" android:layout_toRightOf="@+id/button2" android:text="放大" /> <Button android:id="@+id/button4" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/button3" android:layout_toRightOf="@+id/button3" android:text="输小" /> <WebView android:id="@+id/webView1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignLeft="@+id/button2" android:layout_below="@+id/button2" android:layout_marginLeft="18dp" android:layout_marginTop="116dp" /></RelativeLayout>
访问网络需要加权限
<uses-permission android:name="android.permission.INTERNET"/>
阅读全文
0 0
- WebView混合开发模式二(实现网页的放大,输小等功能)
- WebView混合开发模式一(WebView加载网页)
- Android --- WebView -- 混合开发(二)
- WebView的用法(实现浏览网页功能)
- Android开发--------------WebView(二)之WebView的滑动底部顶部监听,加载进度条等设置
- 混合开发hybrid app(3)怎么增强webview安全功能 和 适配不同手机分辨率的html
- Fragment中加载网页(WebView)监听Back键 ,实现返回上一页的功能
- Android 浏览器开发中的小技巧,webview的复制功能
- iOS开发加载网页(webview)时的菊花(小圈)
- android h5 js 混合开发解决webview加载白屏,不加载网页的问题(硬件加速网页渲染,优化体验)
- 工作中碰到的那些坑(二)-安卓混合开发webview打开链接出错
- 解决WebView加载的网页被放大的问题
- android用WebView显示包含文字和图片的本地网页(支持放大缩小)
- 网页相关小功能实现
- 利用jsoup实现WebView使用默认图片替换img、无图模式等功能
- Qt 图片浏览器 实现图片的放大缩小翻转等功能
- Android多点触控技术,实现对图片的放大缩小平移,惯性滑动等功能
- Android多点触控技术,实现对图片的放大缩小平移,惯性滑动等功能
- 栈的链式存储结构
- redis存取删数据
- ShiftCNN —— 基于量化的低精度网络表达
- Redis学习笔记 (四) 之KEY相关命令
- SQL数据库操作命令大全
- WebView混合开发模式二(实现网页的放大,输小等功能)
- 直播测试源地址
- php解析json
- 笔记:IIS服务器中设置上传文件的大小
- 关于会话与缓存
- 手册网址大全
- eclipse的jocky的配置以及使用
- git由于网络原因导致 please make sure you have the correct access rights and the repository exists
- awk出现求和平均数