How to remove the WebView top/left 8-pixel inner margin?

by Mattaku Betsujin » Mon, 13 Apr 2009 20:23:22 GMT

Sponsored Links
 I think the margin is probably implemented in C code inside WebKit. I looked
at this in the past as well and couldn't find any Java options to configure
the margins.

What do you mean by accuracy? Do you mean finding the exact position of your
HTML objects inside the WebView?


How to remove the WebView top/left 8-pixel inner margin?

by Mattaku Betsujin » Tue, 14 Apr 2009 05:27:53 GMT

 There is a hack to do what you want -- make your WebView into a width of 336
-- that way you will have extra 8 pixels on each side. Then, put in
somewhere off screen (use absolute layout), and get a drawing cache from it.
That way, you can use the drawing cache bitmap, and draw that onto the real
screen (minus the 8 pixel borders).

You should also override the onDraw() method. This way you know whenever the
webview changes, and reload your drawing cache.

If you want to handle user input, that would require more hacks so that you
can feed the events to the webview.

I have not exactly done this before, but I have been using WebView in
hackish ways and I think this might work.

Good luck!


Sponsored Links

How to remove the WebView top/left 8-pixel inner margin?

by Mattaku Betsujin » Tue, 14 Apr 2009 05:49:18 GMT

 Oh, come to think of it, (assuming you want a WebView banner at the top of
the screen) if you use AbsoluteLayout, you can put the WebView at (-8,-8).
This can get rid of the top,left, and right edge.

Then, place another View over the bottom edge of the WebView to cover that
part as well. this way, you have the visible areas of the WebView to extend
exactly to where you want it.

On Mon, Apr 13, 2009 at 2:25 PM, Mattaku Betsujin <


Other Threads

1. Updating GridView child

Managed to solve the problem, it was related to getView being called 
multiple times for the first item (in fact, for all items, but the first 
item was having an earlier View object than the last getView call, meaning 
the reference to the View in the object array was pointing to a view android 
was using for some calculations and not the one it was displaying on screen.

The solution: I've refactored most of my UI updating code and now the UI 
update call invalidates the GridView if the data in any visible list item 
has changed. I've also created a class extending LinearLayout which I've 
used for the list item layout, meaning the layout object can handle 
displaying its own data.

For anyone else getting the same problem, here's some links that were 


2. camera preview problem


I would like to try the camera preview function. I create a new
project, copy the sample code ( from ApiDemo, and
run on HTC G1. Nothing appear. The logcat shows:

I/ActivityManager(   56): Starting activity: Intent { flags=0x10000000
com.example.camerapreview.CameraPreview} }
W/ActivityManager(   56): Permission Denial: starting Intent
{ flags=0x10000000 comp={com.example.camerapreview/
com.example.camerapreview.CameraPreview} } from null (pid=-1, uid=-1)
requires android.permission.CAMERA
D/AndroidRuntime( 9049): Shutting down VM
W/dalvikvm( 9049): threadid=3: thread exiting with uncaught exception
E/AndroidRuntime( 9049): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 9049): *** EXCEPTION IN SYSTEM PROCESS.  System will

My manifest is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    <application android:icon="@drawable/icon" android:label="@string/
app_name" android:debuggable="true"
        <activity android:name=".CameraPreview"
                <action android:name="android.intent.action.MAIN" />
android:name="android.intent.category.LAUNCHER" />
    <uses-sdk android:minSdkVersion="3" />

Could anyone give me a hint what's wrong?


3. Problem in playing MP3 over RTSP streaming on Android Phones

4. Custom Layout and big view in smaller layout

5. ColdFusion and Android development

6. Apk to detect external USB keyboard

7. How to call web services in Android emulator