標籤:hybrid app adnroid web html
在如今的移動開發中,越來越多的web元素加入到了app裡面,hybrid app能夠綜合native app 和 web app的優點,可以通過webView實現
htmllayout.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:orientation="vertical" > <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent" /></LinearLayout>
WebActivity.java
package com.kindergartenParent.activity;import com.kindergartenParent.R;import android.app.Activity;import android.app.AlertDialog;import android.app.AlertDialog.Builder;import android.content.DialogInterface;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.Window;import android.webkit.WebSettings.LayoutAlgorithm;import android.webkit.WebView;import android.widget.ImageButton;import android.widget.TextView;public class WebActivity extends Activity{private ImageButton back;private TextView title;private WebView wv;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.htmllayout);init();Intent intent = this.getIntent();String url = intent.getStringExtra("url");wv.loadUrl(url);}public void init(){wv = (WebView)findViewById(R.id.webview);//支援javascriptwv.getSettings().setJavaScriptEnabled(true); // 設定可以支援縮放 wv.getSettings().setSupportZoom(true); // 設定出現縮放工具 wv.getSettings().setBuiltInZoomControls(true);//擴大比例的縮放//wv.getSettings().setUseWideViewPort(true);//自適應螢幕wv.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);wv.getSettings().setLoadWithOverviewMode(true);}}
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
App中顯示html網頁