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.
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.
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.
String webUrl = webView. getUrl();
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.
Add android:layout_weight='1'
to the WebView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With