2013-03-30 37 views
5

我有一个显示电子邮件内容的活动。 有一个包含收件人和日期的标题以及一个显示邮件内容的web视图。Android Webview:如何滚动整个活动布局

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

但我的问题是,当收件人列表很长,头采用屏幕高度的50%,和web视图只用了50%的屏幕高度,而我只能滚动这50%里面。我想在整个活动布局上滚动(我希望webview能够获得它的全部高度,并且该滚动条出现在整个活动中)。

这是说明我的问题一个画面:

scroll problem

这里是我的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> 

回答

1

为什么不换一个滚动型内收件人列表的东西,然后设置此ScrollView的布局高度为您选择的大小。

这样,他们就可以继续浏览收件人,如果他们愿意并且仍然将大部分屏幕专用于Web视图。

如果你想要一个单一的滚动整个视图,然后做同样的事情,但只是简单地包住一切。

打我了,如果你不明白

+0

大!我用ScrollView将整个布局包围起来,并按照我的意愿滚动​​! – MarneusCalgarXP

+1

我忘了说:非常感谢你;) – MarneusCalgarXP