Can I overlap the WebView with an ImageButton?

我只是一个虾纸丫 提交于 2020-01-17 07:35:51

问题


What I want to create should look like this :

I want it like this because I want the button to cover a part of the content of the webview making it unreachable for the user.


回答1:


You can do it using FrameLayout as follows...

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

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

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:text="Button" />

</FrameLayout>



回答2:


Yes You can do.for that purpose you have to use relative layout.first you have add webview,then add image button and set gravity bottom to image button.i think this can help you.

 <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <WebView 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginBottom="20dp"
            />
        <ImageButton 
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:background="@android:color/darker_gray"
            android:layout_alignParentBottom="true"
            />
    </RelativeLayout>


来源:https://stackoverflow.com/questions/22227904/can-i-overlap-the-webview-with-an-imagebutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!