0

enter image description here

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

1 回答 1

0

当我单击 google 按钮时,它会在 webview 中打开 google 网站,因为您看到它没有全屏打开 google 网站

这是因为您可能正在使用相同布局Activity的相同XML布局,而另一个widgets. 但解决方案并不难。

1.首先用一个小部件创建类似 web.xml 的东西WebView

2.然后创建另一个从 Activity 扩展的类,例如WebBrowser.java

3.将其添加到您的Manifest.xmlas <activity android:name=".WebBrowser"></activity>

4.在您​​的 WebBrowser 类中,将设置您的布局setContentView(R.layout.web)并初始化您的WebView.

5.点击Google Button新建Intent并开始新的Activity

Intent i = new Intent(this, WebBrowser.class);
startActivity(i);


你的web.xml罐头看起来像

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


注意:为了支持全屏,您可以使用

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
于 2012-06-23T09:50:59.380 回答