Stephen McCormick
Stephen McCormick

Reputation: 1796

WebView with buttons on the bottom

Seems pretty simple, but ust can't get this right. Looked at a ton of examples, but I either get the button(s) filling the whole screen or the webview filling the whole screen. I want it to look like this (with the webView filling the screen no matter what the resolution) except that the bottom would have 2 buttons (Yeah they are ugly but I will fix that later):

enter image description here

The XML currently:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/ssoViewerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

       <WebView
           android:id="@+id/ssoViewer"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:layout_weight="0"/>   

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:gravity="center|bottom">      

            <Button
                android:id="@+id/cancelSSO"
                android:layout_marginTop="16dp"
                android:layout_width="125dp"
                android:layout_height="55dp"
                android:layout_margin="5dp"
                android:onClick="cancelSSOClick"
                android:text="Cancel Login"
                android:background="@drawable/button_login" />
            <Button
                android:id="@+id/resetSSO"
                android:layout_marginTop="16dp"
                android:layout_width="125dp"
                android:layout_height="55dp"
                android:layout_margin="5dp"
                android:onClick="resetSSOClick"
                android:text="Reset SSO"
                android:background="@drawable/button_login"/>
    </LinearLayout>
</LinearLayout>

Thanks!

UPDATE

Thanks to Arpit Ratan's answer, with a couple modifications got it to work. The final XML looks like:

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

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:id="@+id/button_layout"
                android:layout_width="match_parent"
                android:orientation="horizontal"
                android:layout_height="wrap_content"
                android:gravity="center|bottom"
                android:layout_alignParentBottom="true">      

                <Button
                    android:id="@+id/cancelSSO"
                    android:layout_marginTop="16dp"
                    android:layout_width="125dp"
                    android:layout_height="55dp"
                    android:layout_margin="5dp"
                    android:onClick="cancelSSOClick"
                    android:text="Cancel Login"
                    android:background="@drawable/button_login" />
                <Button
                    android:id="@+id/resetSSO"
                    android:layout_marginTop="16dp"
                    android:layout_width="125dp"
                    android:layout_height="55dp"
                    android:layout_margin="5dp"
                    android:onClick="resetSSOClick"
                    android:text="Reset SSO"
                    android:background="@drawable/button_login"/>
        </LinearLayout>
     <WebView
               android:id="@+id/ssoViewer"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:layout_above="@id/button_layout" />  
    </RelativeLayout>

Upvotes: 0

Views: 1771

Answers (2)

Lyon12
Lyon12

Reputation: 21

This may be something that you need to put in a fragment, I've seen things like that fight each other for real estate, especially across different devices.

Upvotes: 0

Arpit Ratan
Arpit Ratan

Reputation: 3026

Change it to :

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


                <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:tools="http://schemas.android.com/tools"
                    android:id="@+id/button_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_height="0dip"
                android:gravity="center|bottom"
                android:alighParentBottom="true">      

                <Button
                    android:id="@+id/cancelSSO"
                    android:layout_marginTop="16dp"
                    android:layout_width="125dp"
                    android:layout_height="55dp"
                    android:layout_margin="5dp"
                    android:onClick="cancelSSOClick"
                    android:text="Cancel Login"
                    android:background="@drawable/button_login" />
                <Button
                    android:id="@+id/resetSSO"
                    android:layout_marginTop="16dp"
                    android:layout_width="125dp"
                    android:layout_height="55dp"
                    android:layout_margin="5dp"
                    android:onClick="resetSSOClick"
                    android:text="Reset SSO"
                    android:background="@drawable/button_login"/>
        </LinearLayout>
     <WebView
               android:id="@+id/ssoViewer"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:layout_above="@id/button_layout" />  
    </RelativeLayout>

Upvotes: 2

Related Questions