Paldan
Paldan

Reputation: 435

Android WebView width & height

I have made a WebView and for some reason the borders don't fill the whole screen.

<WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true" />

any suggestions?

Upvotes: 0

Views: 571

Answers (3)

Zankhna
Zankhna

Reputation: 4563

Try this in your XML layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:padding="5dp"/>

</RelativeLayout>

Upvotes: 0

user2534313
user2534313

Reputation:

I believe you wanted give borders to the webview and it should fill the whole screen. Try something like this.

<LinearLayout
            android:id="@+id/ll_webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"            
            android:background="@color/blue_line"
            >

            <WebView
                android:id="@+id/webview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="5dp"
                android:scrollbars="none" />

Upvotes: 0

Siddharth_Vyas
Siddharth_Vyas

Reputation: 10100

You might be having layout above your Webview like Linear,Relative..etc. Remove all the properties from that layout like:

 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"

Try this :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

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

Hope this helps.

Upvotes: 1

Related Questions