我正在以編程方式生成webview我想在web視圖上添加一個按鈕。我可以添加一個正常的按鈕,但是在webview之前,而不是在它之前。如何將按鈕添加到Android上的Webview?
有沒有一種方法可以在webview上添加按鈕?
我正在以編程方式生成webview我想在web視圖上添加一個按鈕。我可以添加一個正常的按鈕,但是在webview之前,而不是在它之前。如何將按鈕添加到Android上的Webview?
有沒有一種方法可以在webview上添加按鈕?
您可以使用FrameLayout(http://developer.android.com/reference/android/widget/FrameLayout.html)將按鈕添加到WebView的頂部。
首先將WebView添加到佈局,然後按鈕並調整按鈕的重力,使其位於您想要的位置。
使用這樣的...
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="500dp"
android:layout_weight="1"
>
<WebView
android:id="@+id/main_web "
android:layout_width="fill_parent"
android:layout_height="500dp"
android:layout_weight="1" />
<ImageButton
android:id="@+id/refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
></ImageButton>
</FrameLayout>
HII ,,,,你可以嘗試在相對佈局(父佈局)網頁視圖和按鈕programatically..And對準所需的按鈕相對於webview的位置... –
這我已經試過這個獲取按鈕和webview並排或一個接一個。我想讓按鈕通過webview – Rishabh
如果您發佈XML佈局文件或者以編程方式嘗試添加按鈕的行,某人將能夠回答此問題。 – Phil