Ian Vink
Ian Vink

Reputation: 68750

Android: Views in ScrollView doesn't appear past empty LinearLayout

On Android 4, I have a simple ScrollView which presents a form to fill in. Inside the view I have a number of buttons, then this Layout,

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

then more buttons. The layout always stops rendering at the LinearLayout. If I move the layout down the list of views, all views above it appear. I can reference the other layouts in code nicely so they are there, just not visible.

Do I need to do something to the LinearLayout to prevent it from stopping the rendering of all the subsequent views?

For reference, here's the full layout:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 android:minWidth="25px"
 android:minHeight="25px"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:fillViewport="true"
 android:id="@+id/scrView">
 <LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_selector">
    <Button
        android:text="Call Crime Stoppers"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btnCall"
        android:layout_marginRight="3dp"
        android:layout_marginLeft="3dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/blue_button_selector"
        android:textSize="25dp"
        android:textColor="@color/white"
        android:drawableLeft="@drawable/phone_element" />
    <TextView
        android:text="About the Incident:"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/lblDescriptionTop"
        android:layout_marginTop="15dp" />
    <Button
        android:text="Take a Picture"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btnPicture"
        android:layout_marginRight="3dp"
        android:layout_marginLeft="3dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/blue_button_selector"
        android:textSize="25dp"
        android:textColor="@color/white"
        android:drawableLeft="@drawable/icon_camera" />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/layoutImages" />
    <Button
        android:text="Location Type"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btnLocationType"
        android:layout_marginRight="3dp"
        android:layout_marginLeft="3dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/blue_button_selector"
        android:textSize="25dp"
        android:textColor="@color/white" />
    <Button
        android:text="Nature of the Incident"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btnNature"
        android:layout_marginRight="3dp"
        android:layout_marginLeft="3dp"
        android:background="@drawable/blue_button_selector"
        android:textSize="25dp"
        android:textColor="@color/white"
        android:layout_marginTop="5dp" />
    <TextView
        android:text="Please Describe:"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/lblDescription"
        android:layout_marginTop="15dp" />
    <EditText
        android:inputType="textMultiLine"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtDescription"
        android:minHeight="150dp"
        android:maxHeight="150dp"
        android:layout_marginTop="5dp"
        android:minWidth="150dp"
        android:maxWidth="150dp" />
    <TextView
        android:text="Optional Contact Info:"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView1"
        android:layout_marginTop="15dp" />
    <CheckBox
        android:text="Use Phone Number?"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/chkPhone" />
    <EditText
        android:inputType="phone"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/editPhone"
        android:hint="Phone Number" />
    <CheckBox
        android:text="Use Email"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/chkEmail" />
    <EditText
        android:inputType="phone"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/editEmail"
        android:hint="Email" />
    <Button
        android:text="Send"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btnSend"
        android:layout_marginRight="3dp"
        android:layout_marginLeft="3dp"
        android:background="@drawable/blue_button_selector"
        android:textSize="25dp"
        android:textColor="@color/white"
        android:layout_marginTop="15dp" />
</LinearLayout>
</ScrollView>

Upvotes: 0

Views: 865

Answers (1)

Frank Sposaro
Frank Sposaro

Reputation: 8531

That is because you have your layout_height set to "fill_parent" so it's taking up the rest of the space below that. That's why it works when it's at the bottom, but not in the middle. Try either changing it to "wrap_content" or using a RelativeLayout.

Upvotes: 2

Related Questions