Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display a WebView

Tags:

android

Has anyone any idea how could I obtain a view that has the following description: At the top at the page there is a custom test , and below there is displayed the content from a url .Currently my layout is the following:

<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>

In the on create of the application tight to this layout I get the TextView with findViewById and set the text for it. Similar I get the WebView and call loadUrl("url") for it, but the behavior is not the expected one. At first the text set is briefly displayed and then a fullscreen browser page with the content from the passed url is shown.

like image 434
klaus johan Avatar asked May 17 '10 16:05

klaus johan


People also ask

How do I view WebView?

Create two Android layout files – “res/layout/main. xml” and “res/layout/webview. xml“. Two activity classes, an activity to display a button, another activity display the WebView with predefined URL.

How do I display HTML content in WebView?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken web view to show html content.

How do I find my WebView URL?

String webUrl = webView. getUrl();

What is a WebView URL?

WebView is a view that display web pages inside your application. You can also specify HTML string and can show it inside your application using WebView. WebView makes turns your application to a web application.


1 Answers

Add android:layout_weight='1' to the WebView.

like image 131
synic Avatar answered Sep 22 '22 15:09

synic