不在新浏览器中打开 webview [英] Opening webview not in new browser

查看:26
本文介绍了不在新浏览器中打开 webview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实施一个网络视图.我想要网页顶部的两个按钮.

I am implementing a webview. I want two buttons on the top of the web page.

我有一个垂直线性布局,里面是一个带有两个按钮的水平布局,以及一个在水平布局之外的 webview.

I have one vertical linear layout, inside of which is one horizontal layout with two buttons, and one webview outside of the horizontal layout.

我只是在 Java 代码中加载 Google URL.

I am simply loading the Google URL in Java code.

每次我运行该应用程序时,它都会在该应用程序顶部打开一个新浏览器,并且按钮被隐藏.它没有显示 webview 上方的按钮.请帮助并告诉我如何在不打开其他浏览器的情况下在 webview 中加载 URL,或者如何通过打开本机浏览器来阻止它,以便在 webview 本身而不是新浏览器中加载页面.

Every time I run the application, it opens a new browser on top of the application and the buttons get hidden. It's not showing the buttons above the webview. Please help and tell me how can I load a URL in the webview without opening another browser, or how I can prevent it by opening a native browser, so that the page is loaded in the webview itself and not a new browser.

谢谢大家

推荐答案

布局应该类似于:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_height="fill_parent"
                 android:layout_width="fill_parent"
                 android:orientation="vertical">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <Button android:id="@+id/button1"
                android:layout_width="0dip"
                android:layout_height="wrap_content"                
                android:layout_gravity="top"
                android:layout_weight="1"/>
            <Button android:id="@+id/button2"
                android:layout_width="0dip"
                android:layout_height="wrap_content"                
                android:layout_gravity="top"
                android:layout_weight="1" />
        </LinearLayout>
        <WebView 
            android:id="@+id/webview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
</LinearLayout>

你也可以参考需要帮助从股票 android 浏览器更改为 webview 以查看您是否正确启动了 url.

And you can also refer to the Need help changing from stock android browser to webview to see if you are launching the url correctly.

这篇关于不在新浏览器中打开 webview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆