0

ここに画像の説明を入力

画像でわかるように、2つのボタンを備えたシンプルなレイアウトがあります.Googleボタンをクリックすると、ウェブビューでGoogleウェブサイトが開きます.フルスクリーンでGoogleウェブサイトを開いているのではなく、これらのボタンが2つ表示されていますメイン レイアウトからスクロールバーを削除すると、webview に Google の Web サイトがフルスクリーンで表示されます。メイン レイアウトでスクロールビューを使用したいので、この問題を解決するにはどうすればよいですか。ここに私の 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ボタンをクリックすると、Google Webサイトが全画面表示されていないことがわかるように、WebビューでGoogle Webサイトが開きます

これはおそらくActivity、同じXMLレイアウトで同じものを使用しているためですwidgets。しかし、解決は難しくありません。

1.まず、1 つのウィジェットで web.xml のようなものを作成しますWebView

2.次に、Activity から拡張する別のクラスを作成します。たとえば、WebBrowser.java

3.Manifest.xmlそれをas <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 に答える