Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Add Button on WebView?

How can I add a button on a WebView?. I have a WebView and I want to show a popup. For that I need to add a button on the bottom-left corner of WebVew. How can I do this?

like image 413
Sanal MS Avatar asked Dec 13 '22 16:12

Sanal MS


1 Answers

I would use a RelativeLayout. I like using it a lot. Its a great way to easily place and organize views,buttons,layouts,etc...

Some Example code:

 <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FFFFD0">

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

        <Button
            android:id="@+id/My_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true"
            android:text="My Button!" />
    </RelativeLayout>

I think the views and buttons will be drawn in order from top to bottom in the XML, but it may be the other way around.use margins like :

android:layout_marginLeft="15dip" and android:layout_marginBottom="10dip"
to help adjust the position.

like image 94
Wayner Avatar answered Dec 15 '22 09:12

Wayner