using System;
using Android.App;
using Android.OS;
using Android.Widget;
using System.IO;
using Android.Webkit;
using Android.Graphics;
using Android.Graphics.Drawables;
using Android.Util;
using Java.IO;
using System.Diagnostics;
namespace test
{
[Activity (Label = "test", MainLauncher = true)]
public class Activity1 : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.myButton);
WebView webview = FindViewById<WebView>(Resource.Id.webView1);
string id = "103230006";
webview.LoadUrl("www.google.com");
button.Click += delegate
{
Picture picture = webview.CapturePicture();
Bitmap bmp = Bitmap.CreateBitmap(picture.Width , picture.Height
, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(bmp);
picture.Draw(canvas);
FileStream fs = new FileStream("/storage/sdcard0/file.jpg", FileMode.Create, FileAccess.Write);
bmp.Compress(Bitmap.CompressFormat.Jpeg, 80, fs);
fs.Close();
};
}
}
}
using Android.App;
using Android.OS;
using Android.Widget;
using System.IO;
using Android.Webkit;
using Android.Graphics;
using Android.Graphics.Drawables;
using Android.Util;
using Java.IO;
using System.Diagnostics;
namespace test
{
[Activity (Label = "test", MainLauncher = true)]
public class Activity1 : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.myButton);
WebView webview = FindViewById<WebView>(Resource.Id.webView1);
string id = "103230006";
webview.LoadUrl("www.google.com");
button.Click += delegate
{
Picture picture = webview.CapturePicture();
Bitmap bmp = Bitmap.CreateBitmap(picture.Width , picture.Height
, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(bmp);
picture.Draw(canvas);
FileStream fs = new FileStream("/storage/sdcard0/file.jpg", FileMode.Create, FileAccess.Write);
bmp.Compress(Bitmap.CompressFormat.Jpeg, 80, fs);
fs.Close();
};
}
}
}
==========================LAYOUT================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:orientation="vertical"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="fill_parent"
p1:layout_height="fill_parent"
p1:id="@+id/linearLayout1">
<WebView
p1:layout_width="fill_parent"
p1:layout_height="wrap_content"
p1:id="@+id/webView1"
p1:layout_marginBottom="30dp" />
<Button
p1:text="Button"
p1:layout_width="fill_parent"
p1:layout_height="wrap_content"
p1:id="@+id/myButton" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:orientation="vertical"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="fill_parent"
p1:layout_height="fill_parent"
p1:id="@+id/linearLayout1">
<WebView
p1:layout_width="fill_parent"
p1:layout_height="wrap_content"
p1:id="@+id/webView1"
p1:layout_marginBottom="30dp" />
<Button
p1:text="Button"
p1:layout_width="fill_parent"
p1:layout_height="wrap_content"
p1:id="@+id/myButton" />
</LinearLayout>