0

My root element is relative layout, within which I have one LinearLayout wrapped into a scrollview. The LinearLayout has multiple children that include textViews, editText, and other Linearlayouts that have textviews and editText. Looked into several SO posts, but no help. All I get is a grey bar on the right of the screen,which scrolls just an inch max, can't scroll any further down.The last few components are only half visible and scrolling does not happen until the bottom where my last components are visible. Setting the viewport parameter to true/false has no effect. Any help will be appreciated.

<RelativeLayout
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"
android:background="@drawable/bg_plain"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Testactivity">

<TextView
    android:id="@+id/tv_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerInParent="true"
    android:layout_marginTop="40dp"
    android:gravity="center"
    android:singleLine="true"
    android:text="INFORMATION"
    android:textAlignment="center"
    android:textColor="#6D6E71"
    android:textSize="25sp"
    />

<ScrollView
    android:layout_width="300dp"
    android:layout_height="560dp"
    android:layout_below="@+id/tv_title"
    android:layout_centerInParent="true"
    android:fillViewport="true"
    >

    <LinearLayout
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginTop="10dp"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/tv_firstname"
                android:layout_width="170dp"
                android:layout_height="30dp"
                android:layout_gravity="left"
                android:gravity="left|center"
                android:text="FIRST NAME*"
                android:textColor="#E96F34"
                android:textSize="16sp"
                />

            <TextView
                android:id="@+id/tv_lastname"
                android:layout_width="130dp"
                android:layout_height="30dp"
                android:layout_gravity="left"
                android:gravity="left|center"
                android:text="LAST NAME*"
                android:textColor="#E96F34"
                android:textSize="16sp"
                />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:orientation="horizontal">

            <EditText
                android:id="@+id/et_firstname"
                android:layout_width="130dp"
                android:layout_height="30dp"
                android:background="@drawable/orange_full_rounded_corner"
                android:gravity="center"
                android:inputType="textPersonName"
                android:maxLength="3"
                />

            <Space
                android:layout_width="40dp"
                android:layout_height="30dp"/>

            <EditText
                android:id="@+id/et_lastname"
                android:layout_width="130dp"
                android:layout_height="30dp"
                android:background="@drawable/orange_full_rounded_corner"
                android:gravity="center"
                android:inputType="textPersonName"
                />
        </LinearLayout>

        <TextView
            android:id="@+id/tv_titlein"
            android:layout_width="170dp"
            android:layout_height="30dp"
            android:layout_gravity="left"
            android:gravity="left|center"
            android:text="TITLE"
            android:textColor="#E96F34"
            android:textSize="16sp"
            />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:orientation="horizontal">

            <RadioGroup
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <RadioButton
                    android:id="@+id/cb_mr"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/orange_full_rounded_corner"
                    android:gravity="center"
                    android:text="MR."
                    />

                <Space
                    android:layout_width="30dp"
                    android:layout_height="match_parent"/>

                <RadioButton
                    android:id="@+id/cb_mrs"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/orange_full_rounded_corner"
                    android:gravity="center"
                    android:text="MRS./MS."
                    />
            </RadioGroup>
        </LinearLayout>

        <TextView
            android:id="@+id/tv_company"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_gravity="left"
            android:gravity="left|center"
            android:text="COMPANY"
            android:textColor="#E96F34"
            android:textSize="16sp"
            />

        <EditText
            android:id="@+id/et_company"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="@drawable/orange_full_rounded_corner"
            android:gravity="center"
            android:inputType="number"
            />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/tv_phone"
                android:layout_width="170dp"
                android:layout_height="30dp"
                android:layout_gravity="left"
                android:gravity="left|center"
                android:text="PHONE*"
                android:textColor="#E96F34"
                android:textSize="16sp"
                />

            <TextView
                android:id="@+id/tv_mobilephone"
                android:layout_width="130dp"
                android:layout_height="30dp"
                android:layout_gravity="left"
                android:gravity="left|center"
                android:text="MOBILE PHONE*"
                android:textColor="#E96F34"
                android:textSize="16sp"
                />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:orientation="horizontal">

            <EditText
                android:id="@+id/et_phone"
                android:layout_width="130dp"
                android:layout_height="30dp"
                android:background="@drawable/orange_full_rounded_corner"
                android:gravity="center"
                android:inputType="number"
                android:maxLength="3"
                />

            <Space
                android:layout_width="40dp"
                android:layout_height="30dp"/>

            <EditText
                android:id="@+id/et_mobilephone"
                android:layout_width="130dp"
                android:layout_height="30dp"
                android:background="@drawable/orange_full_rounded_corner"
                android:gravity="center"
                android:inputType="number"
                />
        </LinearLayout>

        <TextView
            android:id="@+id/tv_emailaddress"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_gravity="left"
            android:gravity="left|center"
            android:text="EMAIL*"
            android:textColor="#E96F34"
            android:textSize="16sp"
            />

        <EditText
            android:id="@+id/et_emailaddress"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="@drawable/orange_full_rounded_corner"
            android:gravity="center"
            android:inputType="textEmailAddress"
            />

        <TextView
            android:id="@+id/tv_address"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_gravity="left"
            android:gravity="left|center"
            android:text="ADDRESS"
            android:textColor="#E96F34"
            android:textSize="16sp"
            />

        <EditText
            android:id="@+id/et_address"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="@drawable/orange_full_rounded_corner"
            android:gravity="center"
            android:inputType="text"
            />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/tv_city"
                android:layout_width="170dp"
                android:layout_height="30dp"
                android:layout_gravity="left"
                android:gravity="left|center"
                android:text="CITY"
                android:textColor="#E96F34"
                android:textSize="16sp"
                />

            <TextView
                android:id="@+id/tv_zipcode"
                android:layout_width="130dp"
                android:layout_height="30dp"
                android:layout_gravity="left"
                android:gravity="left|center"
                android:text="ZIP CODE"
                android:textColor="#E96F34"
                android:textSize="16sp"
                />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:orientation="horizontal">

            <EditText
                android:id="@+id/et_city"
                android:layout_width="130dp"
                android:layout_height="30dp"
                android:background="@drawable/orange_full_rounded_corner"
                android:gravity="center"
                android:inputType="text"
                android:maxLength="3"
                />

            <Space
                android:layout_width="40dp"
                android:layout_height="30dp"/>

            <EditText
                android:id="@+id/et_zipcode"
                android:layout_width="130dp"
                android:layout_height="30dp"
                android:background="@drawable/orange_full_rounded_corner"
                android:gravity="center"
                />
        </LinearLayout>
    </LinearLayout>
</ScrollView>

Ganga
  • 578
  • 1
  • 6
  • 20
  • The purpose of you layout is not very clear, but I think what you are looking for is a ListView, did you try it? – Chisko May 20 '16 at 20:57
  • The layout is just a form with fields. ListView requires a harder implementation as the children are heterogenous type layouts. I was expecting a simple scrollview should be sufficient for this. The contents are static and i just need to get the input values from the form. It was exceeding beyond the screensize, so decided to wrap it within a scrollview which does not give the expected output.. – Ganga May 20 '16 at 20:59
  • Is your RelativeLayout tag closed? It doesn't appear so in your snippet – Chisko May 20 '16 at 21:04
  • Yes it is.. somehow SO truncated it, i too checked why it was not showing. I might have exceeded the line limit for the post. – Ganga May 20 '16 at 21:05
  • You have a RelativeLayout as root, but are not specifying child relative alignment. Try changing it to Linear, or specify child alignment. – Chisko May 27 '16 at 16:56
  • Also, please let me know if it works so I can change it to an answer :) – Chisko May 27 '16 at 16:56
  • Please consider upvoting my answer if it was useful to you. Thank you – Chisko Jun 15 '16 at 17:45

1 Answers1

0

Your layout structure is fine. The problem is you are setting a specified height for almost everything, that's a no no. If you want to work with font height, there's a property called

android:textSize

in all views related to text, and the preferred unit is sp for text, dp for images.

Change all heights to

wrap_content
Chisko
  • 2,935
  • 6
  • 24
  • 41