显示一个 WebView

5

有人知道我如何获得以下描述的视图吗: 页面顶部是自定义文本,下面显示来自url的内容。目前我的布局如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     >
    <TextView  
        android:id="@id+/test"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
    />

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

</LinearLayout>

在与此布局相关的应用程序的onCreate方法中,我使用findViewById获取TextView并设置其文本。同样地,我获取WebView并为其调用loadUrl("url")方法,但行为不是我们所期望的。首先,设置的文本会短暂地显示,然后会显示一个全屏浏览器页面,其中包含传递的URL的内容。
1个回答

5
android:layout_weight='1' 添加到 WebView。

它可以工作。不过,WebView 不在文本下面,而是似乎在 WebView 的表面上呈现了文本。 - klaus johan
嗯,我刚刚创建了一个测试应用程序,它对我来说是有效的。也许你的代码中还有其他问题导致了这个问题? - synic

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接