views:

177

answers:

2

I am working on an app for my company. One of the buttons loads a webview of a google calendar. This works pretty well and all of my other webviews scroll appropriately. However when loading this calendar it resizes to the screen size and will not scroll. I tried setting the webview in a linear layout and making the height of the webview 4096px. This extends the calendar beyond the bottom of the screen, however it will not scroll. I am learning android as I go, I have some programming experience back when I was young and all command line.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="4096px">


<WebView 
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="1020px"></WebView>

</LinearLayout>

The code is

WebView calendar = (WebView) findViewById(R.id.webview);
    calendar.setBackgroundColor(0);
    calendar.setScrollBarStyle(3);
    calendar.getSettings().setJavaScriptEnabled(true);


    Toast.makeText(getApplicationContext(), "Loading Events Calendar", Toast.LENGTH_SHORT).show();

    calendar.loadUrl("http://www.google.com/calendar/embed?src=blahblah%40blah.com&amp;mode=Agenda");

Javascript is enabled for for the webview. Any help would be greatly appreciated.

A: 

change your Linearlayout and WebView layout declaration to::

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

and

<WebView 
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</WebView>
Jorgesys
This code change did not work. It only shows the title of the calendar with this code. I changed the android:layout_height to 2000px and the calendar does extend beyond the bottom of the screen, but will not scroll. Am I using the wrong layout? Does the javascript have something to do with it?
Phobos
A: 

The solution I found to this is to host the calendar on my website. With an embedded width and height defined by the webpage I was able to control the action of the calendar in the webview.

This does not let the calendar, in javascript, resize itself to the screen size, but instead forces a certain perspective. If you make the width of the calendar smaller than the screen size it will fill the width of the screen size. For example if I embed the calendar at a width of 300 it will resize to 480 on my droid. However if you embed the calendar with a width of say 600, it will not resize down.

Hope this helps someone else.

Phobos