1. Create a Cordova project with a command
Cordova coreate Hello Com.example.hello Hello
2. Open Mainactivity
In the OnCreate method, add
Setcontentview (r.layout.main_activity);
3. main_activity files are as follows:
<?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 " > <relativelayout android:layout_width= "fill_parent" android:layout_height= "45dip" android:b ackground= "#25C28B" > <imagebutton android:id= "@+id/cordova_back" android:layout_width= "Wrap_content" android:layout_height= "match_parent" android:background= "#00FFFFFF" Androi d:paddingleft= "10DP" android:paddingright= "20DP" android:src= "@drawable/back_all"/> <t Extview android:id= "@+id/cordova_title" android:layout_width= "Wrap_content" android:layou t_height= "Wrap_content" android:layout_centerinparent= "true" android:text= "native Head" Android: Textcolor= "#FFFFFF" AndroidOid:textsize= "20sp"/> <button android:id= "@+id/btn_report" android:layout_width= "Wrap_ Content "android:layout_height=" Match_parent "android:layout_alignparentright=" true "Android Oid:background= "#00FFFFFF" android:paddingleft= "10DP" android:paddingright= "20DP" Android : text= "Report" android:textcolor= "#FFFFFF" android:textsize= "20sp"/> </RelativeLayout> & Lt;org.apache.cordova.engine.systemwebview android:id= "@+id/cordovawebview" android:layout_width= "Match_pare NT "android:layout_height=" Match_parent "/></linearlayout>
Systemwebview is an extended WebView
4. Re-Makewebview method and Createviews method
@Override protected Cordovawebview Makewebview () { Systemwebview WebView = (systemwebview) Findviewbyid ( R.id.cordovawebview); Cordovawebview Cordovawebview = new Cordovawebviewimpl (new Systemwebviewengine (WebView)); return cordovawebview; }
Cordovawebview for Systemwebview controls in XML
@Override protected void Createviews () { if (preferences.contains ("BackgroundColor")) { int BackgroundColor = Preferences.getinteger ("BackgroundColor", color.black); Background of activity: Appview.getview (). SetBackgroundColor (backgroundcolor); Appview.getview (). Requestfocusfromtouch (); }
5.
Phonegap native Control (Android) mixed with HTML