安卓开发之UIwebview
web view在安卓开发中是比较常见的UI,像微信的新闻模块就采用了这个,他的作用越来越广,下面我把以前做的贴了出来,如果有更好的办法,希望大神不吝赐教哈,嘿嘿,纯代码来了:
java代码
public class GuanYuWoMen extends Activity {
WebView webView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(android.view.Window.FEATURE_NO_TITLE);
setContentView(R.layout.guanyuruanjian);
WebView webview = (WebView)findViewById(R.id.web);
// WebSettings webSettings= webView.getSettings();
//支持javascript
webview.getSettings().setJavaScriptEnabled(true);
// 设置可以支持缩放
webview.getSettings().setSupportZoom(true);
// 设置出现缩放工具
webview.getSettings().setBuiltInZoomControls(true);
//扩大比例的缩放
webview.getSettings().setUseWideViewPort(true);
//自适应屏幕
webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
/*
* 加载网页进度条
* */
webview.setWebChromeClient(new WebChromeClient(){
public void onProgressChanged(WebView view, int progress) {
//Activity和Webview根据加载程度决定进度条的进度大小
//当加载到100%的时候 进度条自动消失
GuanYuWoMen.this.setProgress(progress * 100);
ProgressBar loadingProgress=(ProgressBar)findViewById(R.id.pgs);//此控件为一个进度条控件,属于自己添加的控件这个样式是可以进行改变的
loadingProgress.setProgress(progress);
if (progress==100) {
loadingProgress.setVisibility(loadingProgress.GONE);
}
super.onProgressChanged(view, progress);
}
});
webview.loadUrl("http://www.buiqu.com/");
}
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C6C6C6"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/title_beijing" >
<ImageView
android:id="@+id/img_shezhi_fanhui"
android:layout_width="45dp"
android:background="@drawable/fanhui"
android:layout_marginLeft="5dp"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textColor="#fff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#fff"
android:layout_centerInParent="true"
android:text="@string/shezhi"
android:textSize="20dp" />
</RelativeLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:id="@+id/layout_xiugaiphone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:textSize="15sp"
android:text="@string/xiugai_phone"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="right"
android:text=">"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:id="@+id/layout_shezhianquanwenti"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:textSize="15sp"
android:text="@string/shezhianquanwenti"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="right"
android:text=">"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:id="@+id/layout_guanyuwomen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal" >
<TextView
android:id="@+id/gywm_gywm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="15sp"
android:layout_marginLeft="5dp"
android:text="关于我们"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="right"
android:text=">"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:id="@+id/layout_zhanghao"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:textSize="15sp"
android:text="@string/tuichu"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="right"
android:text=">"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:id="@+id/layout_chengxun"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal" >
<TextView
android:id="@+id/gywm_tcyy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="15sp"
android:layout_marginLeft="5dp"
android:text="@string/tuichuyingyong"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="right"
android:text=">"
android:textSize="18dp" />
</LinearLayout>
</LinearLayout>
安卓开发之UIwebview的更多相关文章
- 安卓开发之Toolbar
根据官网的教程,发现实现与预期不一致,查看相关资料自己整理了一下(官网开发文档:https://developer.android.com/training/appbar/setting-up.htm ...
- 安卓开发之ListAdapter(二)
今天我们来学习一下ArrayAdapter: ArrayAdapter是安卓中最简单的适配器.使用ArrayAdapter(数组适配器),需要把数据源存 放至数组里面来显示. •构造函数: publi ...
- iOS开发之UIWebView自动滑动到顶部-备
但可以通过subview来操作. 通常用UIWebView加载网页,有时候需要点击一个按钮,或者页面的某个部位,使页面自动滚动到顶部,但是UIWebView不像UIScrollView那么方便. ...
- iOS开发之UIWebView的常见一些用法
虽然现在Xcode8已经开始使用WKWebView这个框架进行网页展示,但是UIWebView也有一些常用的方法需要知道,下面就简单展示一下,仅供大家参考 相关知识:1.设置背景透明:2.加载本地HT ...
- iOS开发之UIWebView
转自:http://www.cnblogs.com/zhuqil/archive/2011/07/28/2119923.html UIWebView是iOS sdk中一个最常用的控件.是内置的浏览器控 ...
- 安卓开发之activity详解(sumzom)
app中,一个activity通常是指的一个单独的屏幕,相当于网站里面的一个网页,它是对用户可见的,它上面可以显示一些控件,并且可以监听处理用户的时间做出响应. 那么activity之间如何进行通信呢 ...
- 安卓开发之ListAdapter(一)
Adapter常用来管理数据,是连接后端数据和前端显示的适配器接口,是数据和UI(view)之间一个重要的纽带.再常见的view(listview.gridview)等地方都需要用到adapter,下 ...
- 安卓开发之json解析
1.从网页获取json返回字符串 public class ReadNet extends AsyncTask<URL, Integer, String> { @Override ...
- 安卓开发之viewpager学习(头条显示)
activity_luancher.xml代码如下: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res ...
随机推荐
- 七、L2CAP
1. L2CAP 在BR/EDR模式下,在connection procedure成功执行后,两台设备通过一条物理信道(physical channel)连接在一起,同时两者之间建立起了一条 ...
- LeetCode - 46. Permutations
46. Permutations Problem's Link -------------------------------------------------------------------- ...
- Windows 8 应用商店无法连接到网络的终极完美解决方案
当你看到以下几个步骤的时候,你可能会不以为然,因为你已经试过了,还是没成功,依然提示"你的电脑没有连接到Internet或者现在无法使用Windows应用商店,要使用Windows应用商店, ...
- LINQ的Union方法
2个集合合并,有相同的只取中其一个: source code: , , }; , , }; var result = a.Union(b); result.ForEach(delegate (int ...
- Win10通用程序 UWP版HtmlAgilityPack UWP应用使用示例
Win10 UWP版HtmlAgilityPack,UWP应用使用示例下载. Win10 发布了一个多星期,sdk是随着一起发布的,我安装好vs2015和sdk 开发UWP 通用程序. 在做网络解析的 ...
- 在使用vs2012中的MVC4出的错误!类型“System.Data.Entity.DbContext”在未被引用的程序集中定义
理解决方案的nuget程序包2.选中已安装的包,找到EntityFramework,点击管理 由于我是在Taobao_DAL中用到了EF的“数据上下文对象”,他报错了.所以我们要选中它,将EF5.0安 ...
- IIS8发布WCF接口中遇到的问题总结
环境:系统Win8.1+VS2013+IIS8 在VS13中新建一个WCF服务应用程序,新建之后系统会默认给我们新建一个方法.
- 禅道 Rest API 开发
在老的 PHP 系统中使用 PHP 5.3以后的库 所谓老的系统,是指没有使用PHP 5.3以上命名空间(namespace)特性编码的系统. 但是,只要你的系统运行在 PHP 5.3及以上的环境,在 ...
- [javaSE] 反射-动态加载类
Class.forName(“类的全称”) ①不仅表示了类的类类型,还代表了动态加载类 ②请大家区分编译,运行 ③编译时刻加载类是静态加载类,运行时刻加载类是动态加载类 Ⅰ所有的new对象都是静态加载 ...
- Java集合源码分析(七)HashMap<K, V>
一.HashMap概述 HashMap基于哈希表的 Map 接口的实现.此实现提供所有可选的映射操作,并允许使用 null 值和 null 键.(除了不同步和允许使用 null 之外,HashMap ...