6

我有一个显示电子邮件内容的活动。有一个带有收件人和日期的标题,以及一个用于显示邮件内容的 web 视图。

邮件很长的时候,没问题,webview里面有滚动条。

但是我的问题是当收件人列表很长时,header占屏幕高度的50%,而webview只占屏幕高度的50%,我只能在这50%里面滚动。我想滚动整个活动布局(我希望 webview 得到它的全高,并且滚动条出现在整个活动上)。

这是一张说明我的问题的图片:

滚动问题

这是我的 layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="vertical"
android:scrollbars="horizontal" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@layout/header_gradient" >
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#DEDEDE"
    android:orientation="vertical"
    android:padding="2dp" >

    <TextView
        android:id="@+id/label_mail_object"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="&lt;mail_object>"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/label_mail_from"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="&lt;from>"
        android:textColor="#0000FF" />

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:shrinkColumns="0"
        android:stretchColumns="1" >

        <!-- Send time -->

        <TableRow
            android:id="@+id/tablerow_sent_date"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/label_sent_date"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/label_mail_date"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="&lt;sent_date>" />
        </TableRow>

        <!-- To -->

        <TableRow
            android:id="@+id/tablerow_to"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/label_to"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/label_mail_to"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:maxWidth="@dimen/padding_large"
                android:text="&lt;to>" />

        </TableRow>

        <!-- Cc -->

        <TableRow
            android:id="@+id/tablerow_cc"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/label_cc"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/label_mail_cc"
                 android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:maxWidth="@dimen/padding_large"
                android:text="&lt;cc>" />
        </TableRow>

        <!-- To -->

        <TableRow
            android:id="@+id/tablerow_cci"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/label_cci"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/label_mail_cci"
                 android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:maxWidth="@dimen/padding_large"
                android:text="&lt;cci>" />
        </TableRow>

    </TableLayout>

</LinearLayout>

<View
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="#808080" />

<WebView
    android:id="@+id/webview_mail_preview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

</LinearLayout>
4

1 回答 1

3

为什么不将收件人的列表内容包装在 ScrollView 中,然后将此 ScrollView 的布局高度设置为您选择的大小。

这样,如果他们愿意,他们可以继续滚动接收者的屏幕,并且仍然有大部分屏幕专用于 Web 视图。

如果你想要一个滚动的整个视图,那么做同样的事情,只是简单地包装所有东西。

不明白就打我

于 2013-03-31T06:57:55.623 回答