0
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <WebView
        android:id="@+id/mapview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1.0" />
        <LinearLayout android:id="@+id/TableRow05" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="47dp">
            <Button android:text="@string/Start"  android:id="@+id/StartButton" android:layout_height="wrap_content" android:layout_width="100dp" android:textSize="20sp" ></Button>
            <Button android:text="@string/Exit" android:id="@+id/QuitButton" android:layout_height="wrap_content" android:layout_width="100dp" android:textSize="20sp"></Button>
        </LinearLayout>
        <Button android:text="@string/Stop"  android:id="@+id/StopButton" android:layout_height="wrap_content" android:layout_width="100dp" android:textSize="20sp" android:layout_marginLeft="97dp"></Button>

</LinearLayout>

This is my layout's xml file. I want to add something else under the webview (some buttons like the ones in the example). The problem is that if i call the loadUrl(string) method, i get a full screen page (and i have to go back to the application). What can i do to see a web page only on the upper half of the page?

4

2 回答 2

1

尝试这个 :

WebView myWebView = (WebView) findViewById(R.id.mapview);

class MyWebViewClient extends WebViewClient {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                    view.loadUrl(url); // Stay within this webview and load url
                    return true;
            }

    }

myWebView.setWebViewClient(new MyWebViewClient());
myWebView.loadUrl("YOUR URL");
于 2013-10-28T16:21:53.087 回答
0

这在过去对我有用

<RelativeLayout android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    // WebView
</RelativeLayout>
//Buttons
于 2013-10-28T16:02:15.730 回答