Gravity on WebView after loadurl

Issue

Hi I have a WebView defined like the one above:

    <LinearLayout
        android:id"@+id/linearLayout4"
        android:layout_width"0dp"
        android:layout_height"match_parent"
        android:orientation"vertical"
        android:layout_weight"25" >

        <WebView
            android:id"@+id/home_banner"
            android:layout_width"wrap_content"
            android:layout_height"wrap_content"
            android:layout_gravity"center_horizontal"
            android:layout_margin"10dp" />

    </LinearLayout>

When the WebView loads the banner, it lose the gravity attribute, placing it to the left of the LinearLAyout, creating a lot of empty space to the right.

There is any way to fix this issue? Many thanks!

Solution

Try this    

    <WebView
        android:id"@+id/home_banner"
        android:layout_width"match_parent"
        android:layout_height"wrap_content"
        android:layout_margin"10dp" />

Answered By – Tofeeq Ahmad

Leave a Comment