我試圖讓頭部「54dp」,其餘的活動是一個WebView。android webview佔用全屏
當我在eclips中的「圖形佈局」中預覽我的活動時,它看起來不錯。但是當在手機或模擬器上運行應用程序時,webview會佔用整個屏幕。
這是預覽的樣子,我怎麼想的那樣:
但是,這是我所看到的,當我運行的應用程序:
這是什麼佈局xml看起來像:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/page_background"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/Layout_Header"
android:layout_width="fill_parent"
android:layout_height="54dp"
android:orientation="horizontal"
android:background="@drawable/container_header"
android:paddingLeft="16dp"
android:paddingRight="16dp"
>
<ImageView
android:id="@+id/imgHeaderLogo"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="46dp"
android:contentDescription="@string/img_header_logo_description"
android:src="@drawable/header_logo"
android:layout_gravity="center"
/>
</LinearLayout>
<WebView android:id="@+id/web_engine"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
SOLUTION:
在活動的java文件我有這樣的:
WebView browser = (WebView) findViewById(R.id.web_engine);
WebSettings webSettings = browser.getSettings();
setContentView(browser);
當我應該有這樣的:
setContentView(R.layout.activity_sign_in_web_view);
我說得太快......這應該有效。但只要我把代碼加載一個頁面......它需要整個屏幕。很奇怪。 – capdragon 2013-02-21 01:11:31
想通了......謝謝!給你信用,因爲使用體重填充它最好。我發佈了一個更新到我的答案。 – capdragon 2013-02-21 15:43:41