Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Webview : How to scroll the whole activity layout

I have an activity that displays the content of an email. There is a header with recipients and date, and a webview to display mail content.

When the mail is very long, no problem, there are scrollbars inside the webview.

But my problem is when the recipient list is very long, the header takes 50% of the screen height, and the webview takes only 50% of the screen height, and I can only scroll inside these 50%. I would like to scroll on the whole activity layout (I would like that the webview gets its full height, and that scrollbar appear on the whole activity).

Here is a picture illustrating my problem :

scroll problem

Here is my 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>
like image 918
MarneusCalgarXP Avatar asked Mar 30 '13 22:03

MarneusCalgarXP


1 Answers

why not just wrap the recipient's list stuff within a ScrollView, and then set this ScrollView's layout height to a size of your choosing.

This way they can go ahead and scroll through the the recipient's if they desire and still have the majority of the screen dedicated to the Web view.

If you want the whole view with a single scroll, then do the same but simply wrap everything.

Hit me up if you don't understand

like image 122
rennoDeniro Avatar answered Nov 06 '22 11:11

rennoDeniro