Steve Boo
Steve Boo

Reputation: 23

Add space below Webview

I have a webview and when its scrolled down there appears a switch. My problem is that the switch is overlapping the last line of the webview. I tried to set a padding for the parent layout but the problem with that is that its always showing. Can I add something inside the webview to add space at the bottom? Or can I add something inside the surrounding relative layout?

Edit:

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
    android:orientation="vertical">

<WebView
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</RelativeLayout>

<android.support.v7.widget.SwitchCompat
    android:id="@+id/opt_out_switch"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:alpha="0"
    android:background="#FFEFEEEE"
    android:text="@string/optout"
    android:theme="@style/switchTheme" />

<ProgressBar
    android:id="@+id/progressBar"
    style="@style/Widget.AppCompat.ProgressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:visibility="gone" />
</RelativeLayout>

Upvotes: 2

Views: 439

Answers (1)

user4035628
user4035628

Reputation:

Use LinearLayout to achieve what you need:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <android.support.v7.widget.SwitchCompat
        android:id="@+id/opt_out_switch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:alpha="0"
        android:background="#FFEFEEEE"
        android:text="@string/optout"
        android:theme="@style/switchTheme" />

    <ProgressBar
        android:id="@+id/progressBar"
        style="@style/Widget.AppCompat.ProgressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

Upvotes: 2

Related Questions