Android webview全屏

时间:2012-08-23 10:32:22

标签: android android-layout android-webview

我有一个布局,我需要在屏幕的一部分上显示webview。我已经设置了布局,在Eclipse中的图形布局中,它看起来像我想要的那样(徽标和标题涂黑):

Layout as shown in the Graphical Layout

但是,当我在模拟器或手机中打开此布局时,它会将WebView显示为全屏。我如何制作这样的布局?非常感谢任何帮助!

这是我的XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/Theme.KB_default"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/header_background_shape" >
        <TextView
            android:id="@+id/heading"
            style="@style/Theme.KB_header"
            android:layout_width="wrap_content"
            android:layout_centerHorizontal="true"
            android:text="@string/app_name" >
        </TextView>
        <ImageView
            android:id="@+id/imageViewPadlock"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dp"
            android:contentDescription="@string/global_secure_connection"
            android:src="@drawable/padlock" />
    </RelativeLayout>
    <View
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:background="@color/black" >
    </View>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="0.41"
        android:orientation="vertical" >
        <WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="40dp"
            android:layout_height="20dp"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="15dp"
            android:contentDescription="@string/global_logo"
            android:scaleType="fitXY"
            android:src="@drawable/logo_transparrent_notext" />
    </LinearLayout>
</LinearLayout>

2 个答案:

答案 0 :(得分:0)

将一个表格块作为webview

检查此链接

http://developer.android.com/reference/android/widget/TableLayout.html

您也可以使用对话框

来查看此示例

http://www.41post.com/4673/programming/android-creating-a-webview-dialog

答案 1 :(得分:0)

好吧,我似乎是活着最愚蠢的人。我的布局工作但我忘了添加“setContentView(xml.file);”所以它永远不会加载XML ...愚蠢