1

i have a ScrollView in android, inside it i have a RelativeLayout, my problem its the scroll doesnt go to the end and i cant see the last TextView.

This is the XML

<!-- Main layout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TabOrderActivity$OrderDetailFragment"
    android:orientation="vertical"
    android:background="@drawable/fondodroid2"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:weightSum="1">

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/blue_gg"
        android:paddingTop="5dip">

        <TextView
            android:text="@string/orderDetail"
            android:textSize="32sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:textColor="@android:color/white" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="5dip"
        android:paddingBottom="5dip"
        android:orientation="horizontal">

        <TextView
            android:text="Nº"
            android:textSize="28sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:textStyle="bold"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp" />

        <TextView
            android:id="@+id/file"
            android:textSize="28sp"
            android:layout_marginLeft="20dp"
            style="@style/orderHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:layout_marginTop="10dp"
            android:layout_weight="2.16"
            android:layout_marginRight="0dp"
            android:text="numero de orden" />

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:id="@+id/scrollView">


            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp">

                <TextView
                    android:id="@+id/policyHolderLabel"
                    style="@style/orderHeader"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/customer"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:gravity="left|top"
                    android:textSize="24dp"
                    android:layout_alignParentLeft="true"
                    android:layout_marginTop="0dp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/policyHolder"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:layout_toRightOf="@+id/policyHolderLabel"
                    android:gravity="left|top"
                    android:layout_marginLeft="10dp"
                    android:textSize="20sp" />

                <TextView
                    android:id="@+id/cityLabel"
                    style="@style/orderHeader"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/city"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:layout_below="@+id/policyHolder"
                    android:layout_alignParentLeft="true"
                    android:layout_marginTop="10dp"
                    android:gravity="left|top"
                    android:textSize="24dp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/city"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:layout_toRightOf="@+id/cityLabel"
                    android:gravity="left|top"
                    android:layout_marginLeft="10dp"
                    android:textSize="20sp"
                    android:layout_alignBottom="@+id/cityLabel" />

                <TextView
                    android:id="@+id/provinceLabel"
                    style="@style/orderHeader"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/province"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:layout_below="@+id/city"
                    android:layout_alignParentLeft="true"
                    android:layout_marginTop="10dp"
                    android:gravity="left|top"
                    android:textSize="24dp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/province"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:gravity="left|top"
                    android:layout_toRightOf="@+id/provinceLabel"
                    android:layout_marginLeft="10dp"
                    android:textSize="20sp"
                    android:layout_alignBottom="@+id/provinceLabel" />

                <TextView
                    android:id="@+id/addressLabel"
                    style="@style/orderHeader"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/address"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:layout_marginTop="10dp"
                    android:gravity="left|top"
                    android:textSize="24dp"
                    android:layout_below="@+id/province"
                    android:layout_alignParentLeft="true"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/address"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:gravity="left|top"
                    android:layout_toRightOf="@+id/addressLabel"
                    android:layout_marginLeft="10dp"
                    android:textSize="20sp"
                    android:layout_alignBottom="@+id/addressLabel" />

                <TextView
                    android:id="@+id/zipCode"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:gravity="left|top"
                    android:layout_toRightOf="@+id/addressLabel"
                    android:layout_below="@+id/address"
                    android:layout_marginLeft="10dp" />

                <TextView
                    android:id="@+id/phonesLabel"
                    style="@style/orderHeader"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/phones"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:gravity="left|top"
                    android:layout_below="@+id/zipCode"
                    android:layout_alignParentLeft="true"
                    android:layout_marginTop="10dp"
                    android:textSize="24dp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/phone1"
                    android:inputType="phone"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="left|top"
                    android:textSize="20sp"
                    android:layout_toRightOf="@+id/phonesLabel"
                    android:layout_marginLeft="10dp"
                    android:layout_alignBottom="@+id/phonesLabel" />

                <TextView
                    android:id="@+id/descriptionLabel"
                    style="@style/orderHeader"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/description"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:layout_below="@+id/phonesLabel"
                    android:layout_alignParentLeft="true"
                    android:layout_marginTop="10dp"
                    android:gravity="left|top"
                    android:textSize="24dp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/description"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/descriptionLabel"
                    android:layout_below="@+id/descriptionLabel"
                    android:layout_marginTop="10dp"
                    android:editable="false"
                    android:inputType="textMultiLine"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:gravity="left|top"
                    android:textSize="20sp"
                    android:layout_marginBottom="10dp" />

                <TextView
                    android:id="@+id/coverageLabel"
                    style="@style/orderHeader"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/Cobertura"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:layout_below="@+id/description"
                    android:layout_alignParentLeft="true"
                    android:layout_marginTop="10dp"
                    android:gravity="left|top"
                    android:textSize="24dp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/coverage"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/coverageLabel"
                    android:layout_below="@+id/coverageLabel"
                    android:layout_marginTop="10dp"
                    android:editable="false"
                    android:inputType="textMultiLine"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:gravity="left|top"
                    android:textSize="20sp"
                    android:layout_marginBottom="10dp" />


            </RelativeLayout>
    </ScrollView>

</LinearLayout>

I tried to set a LinearLayout inside scrollview and the linearlayout contains the relative but i got the same result.

Whats wrong?

colymore
  • 11,776
  • 13
  • 48
  • 90

1 Answers1

2

Try to change the margins to paddings:

<RelativeLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:paddingTop="20dp"
       android:paddingLeft="10dp"
       android:paddingRight="10dp">

Hope this helps.

luiscosta
  • 855
  • 1
  • 10
  • 16
  • Because you are giving a `marginTop` and then the `ScrollView` won't scroll to the last `20dip` space because the `RelativeLayout` isn't on the proper place it should be. I don't know how to explain it better, sorry! In other words, what you want is to have an inside space between your View and the borders and not an outside space... – luiscosta Jul 25 '14 at 13:40
  • Ok, i think i understand. Thanks, in few minutes i set your aswner as correct. – colymore Jul 25 '14 at 13:45
  • @colymore I just made a quick search to find a good explanation. See this answer: http://stackoverflow.com/a/5958735/3465623 – luiscosta Jul 25 '14 at 14:01