Yes there does seem to be a problem with View.getContentHeight(). I
developed a small app that demonstrates a problem with the value
returned in portrait versus landscape mode. I only tested this in the
emulator using 1.5. When I press Ctrl-F12 to switch orientation
repeatedly, I get 0 in portrait and > 0 in landscape.
Here is the code:
--------------------------------------------------------------------------------------
package com.jackcholt;
import android.util.Log;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class DLSP extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_dlsp);
final WebView dlspView = (WebView) findViewById
(R.id.dlspView);
dlspView.loadData("KEY WEST, Fla. — A ship last used by the
U.S. Air Force to track missiles and spacecraft "
+ "became the world's second-largest intentionally
sunk artificial reef Wednesday. " +
"Using explosives attached to the hull, crews sank the
decommissioned Gen. Hoyt S. "
+ "Vandenberg about seven miles off Key West, Fla. " +
"The scheduled 10 a.m. blast to force the hulking
vessel to the ocean floor was "
+ "delayed by about 20 minutes because of sealife in
the vicinity — specifically, sea turtles. " +
"Officials hope the newly sunken ship will attract
fish and divers and relieve "
+ "recreational pressure on nearby natural reefs. " +
"Beach in the Florida Panhandle.", "text/plain",
"utf-8");
setWebViewClient(dlspView);
}
private void setWebViewClient(final WebView view) {
view.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(final WebView view, final
String url) {
Log.i("DLSP", "Content Height: " +
view.getContentHeight());
}
});
}
}
-----------------------------------------------------------------------------------
Here's view_dlsp.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView android:id="@+id/dlspView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---