I have an activity layout that has 2 EditText and 3 Buttons. I want to apply a scrollview to the whole layout. The last button should always be at the bottom of the layout; it should also belong to the same scrollview as the other EditText and Buttons.
This is a visual description:
What I have done is not allowing the third button to be at the bottom of the layout. We also have to keep in mind that the screen sizes differ, so the positioning of the third button should be dynamic enough to be at the bottom of any screen size and belong to the scrollview as well.
My layout code:
<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:layout_alignParentBottom="false"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:layout_centerVertical="true"
android:orientation="vertical"
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=".AddDetails" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:id="@+id/first_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="92dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<EditText
android:id="@+id/firstNameEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First Name"
android:lines="1"
android:singleLine="true"
android:textSize="24sp" >
</EditText>
<EditText
android:id="@+id/lastNameEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Last Name"
android:lines="1"
android:singleLine="true"
android:textSize="24sp" />
<EditText
android:id="@+id/emailEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email address"
android:inputType="textEmailAddress"
android:lines="1"
android:singleLine="true"
android:textSize="24sp"
android:visibility="gone" />
<Button
android:id="@+id/locationEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:lines="1"
android:singleLine="true"
android:text="Country"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<Button
android:id="@+id/dateOfBirthEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Date of birth"
android:textColor="#FFFFFF"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/first_layout">
<Button
android:id="@+id/nextScreenBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/next_button_selector"
android:text="Next"
android:textColor="#FFFFFF"
android:textSize="20sp" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Please suggest me a way to achieve the same.