1

I have the next xml layout file:

<ViewFlipper android:id="@+id/details"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <!-- ListView que define la lista de noticias -->
    <ListView
        android:id="@+id/list"
        android:cacheColorHint="@android:color/transparent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>

    <!-- Layout del detalle de una noticia -->
    <ScrollView
      android:id="@+id/scroll"  
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="#FFFFFFFF">

        <LinearLayout 
         android:id="@+id/widget"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:orientation="vertical">

            <RelativeLayout android:id="@+id/top"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="2dip"
                android:background="@drawable/header">
                <Button android:id="@+id/back" 
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" 
                    android:layout_marginTop="5.0dip"
                    android:layout_marginLeft="5.0dip"
                    android:padding="5.0dip"
                    android:background="@drawable/custom_buttom"
                    android:text="Atrás" 
                    android:textStyle="bold"
                    android:textSize="11.0dip"
                    android:textColor="#FFFFFF"/>

                <Button android:id="@+id/share"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5.0dip"
                    android:layout_marginRight="5.0dip"
                    android:padding="5.0dip"
                    android:background="@drawable/custom_buttom"
                    android:text="Compartir" 
                    android:textStyle="bold"
                    android:textColor="#FFFFFF"
                    android:textSize="11.0dip"
                    android:layout_alignParentRight="true">
                </Button>
            </RelativeLayout>

            <TextView
              android:id="@+id/title"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:layout_marginTop="12dip"
              android:padding="10dip"
              android:gravity="fill_horizontal"
              android:textStyle="bold"
              android:textSize="22dip"
              android:textColor="#000000"/>

            <TextView
              android:id="@+id/date"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:paddingLeft="10dip"
              android:gravity="left"
              android:textSize="11dip"
              android:textColor="#000000"/>

            <WebView
             android:id="@+id/message"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:layout_marginTop="12dip"
             android:padding="10dip"
             android:gravity="fill_horizontal"
             android:textSize="14dip"
             android:layout_centerInParent="true"/>

            <TextView
              android:id="@+id/source"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:paddingLeft="10dip"
              android:gravity="center"
              android:textSize="11dip"
              android:textColor="#000000"/>
        </LinearLayout>
    </ScrollView>
</ViewFlipper>

where the content in the WebView is dinamically changed depending the item selected in a previous ListView (the first view in the ViewFlipper).

The problem is when I set a new content in the WebView after the view has been filled with text. If the first text set is longer than the next one, the second time I have a large blank space between the finish of the WebView text and the footer I have in the screen. Do anyone know what is the problem ?

Another problem I have is with de focus. The first time I load this view it is focused in the top, but the second one is focused directlly in the WebView.

2 Answers 2

2

I had similar problem. Solved this by using FrameLayout.

Looks like this in the function for page switching for me:

FrameLayout frame = (FrameLayout) findViewById(R.id.frame);
frame.removeAllViews();

WebView webView = new WebView(yourContext); 

// do whatever you need to do with webView

frame.addView(webView);
Sign up to request clarification or add additional context in comments.

Comments

1

In your WebView try replacing
android:layout_height="fill_parent"
with
android:layout_height="wrap_content"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.