i have simple layout with two buttons as you can see in the image , when i click on google button it opens google website in the webview as you see it is not opening google website on full screen it is showing those buttons two ,but when i remove scrollbar from my main layout, then webview shows google website on the full screen, how can i fix this problem because i want to user scrollview in my main layout.. here is my main.xml
xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@+id/btn_click_login"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="2"
android:text="Google"/>
<Button
android:id="@+id/btn_gmail"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="2"
android:text="Gmail"/>
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</WebView>
</LinearLayout>
</ScrollView>
when i click on google button it opens google website in the webview as you see it is not opening google website on full screen
This is because probably you are using same Activity
with same XML
layout, where are another widgets
. But solution is not difficult.
1. First create something like web.xml with one widget WebView
.
2. Then create another class extending from Activity called for example WebBrowser.java
3. Add it to your Manifest.xml
as <activity android:name=".WebBrowser"></activity>
4. In your WebBrowser class will set your layout with setContentView(R.layout.web)
and initialize your WebView
.
5. After clicking on Google Button
create new Intent
and start new Activity
.
Intent i = new Intent(this, WebBrowser.class);
startActivity(i);
your web.xml
can looks like
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Note: For support of full screen you can use
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.