WebView上的Android添加按钮?

San*_* MS 3 android android-layout

如何在WebView?上添加按钮?我有一个WebView,我想显示一个弹出窗口.为此,我需要在WebVew的左下角添加一个按钮.我怎样才能做到这一点?

小智 11

我会使用相对布局.我喜欢使用它.它是轻松放置和组织视图,按钮,布局等的好方法......一些示例代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:background="#FFFFD0"
 android:layout_height="fill_parent"
 >
<WebView 
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
  />
    <Button
        android:id="@+id/My_btn"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:text="My Button!"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"



             />
 </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我认为视图和按钮将按照从上到下的顺序在xml中绘制,但它可能是相反的方式.使用android这样的边距:layout_marginLeft ="15dip"android:layout_marginBottom ="10dip"来帮助调整位置.