Why my element is not staying at the bottom as supposed?



I have this layout xml file:



<ScrollView xmlns:android="http://ift.tt/nIICcg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
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=".MainActivity">

<TextView
android:layout_marginTop="40dp"
android:id="@+id/emalLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/test" />

<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/testTxtLay"
android:layout_marginTop="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/emalLbl"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="1">

<EditText
android:id="@+id/testTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:background="@drawable/edit_text_design" />
</LinearLayout>

<TextView
android:layout_marginTop="60dp"
android:id="@+id/reminderLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/testTxtLay"
android:layout_centerHorizontal="true"
android:text="@string/reminder" />

<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_marginTop="10dp"
android:id="@+id/reminderTxtLay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/reminderLbl"
android:orientation="horizontal"
android:padding="10dp"
android:weightSum="1">

<EditText
android:id="@+id/reminderTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:lines="2"
android:background="@drawable/edit_text_design" />
</LinearLayout>

<View
android:id="@+id/spacer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/reminderTxtLay"
android:layout_centerHorizontal="true" />

<Button
android:layout_marginTop="200dp"
android:id="@+id/pickDateBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/reminderTxtLay"
android:layout_toLeftOf="@+id/spacer"
android:onClick="showDatePickerDialog"
android:text="@string/datePickerBtnTxt" />

<Button
android:id="@+id/pickTimeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/pickDateBtn"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/pickDateBtn"
android:onClick="showTimePickerDialog"
android:text="@string/pickTimeBtn" />

<View
android:id="@+id/spacerTxt"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_below="@id/reminderTxtLay"
android:layout_centerHorizontal="true" />

<EditText
android:layout_marginTop="15dp"
android:id="@+id/selectedDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/spacerTxt"
android:layout_below="@id/pickDateBtn"
android:layout_toLeftOf="@+id/spacerTxt" />

<EditText
android:id="@+id/selectedTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/selectedDate"
android:layout_below="@id/pickTimeBtn"
android:layout_toRightOf="@+id/selectedDate" />

<Button
android:id="@+id/submitBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:onClick="submitData"
android:text="@string/submitBtn" />

</RelativeLayout>
</ScrollView>


This is the custom design for 7 inch tablets, placed in res\layout-sw600dp


Anyways in the android studio landscape preview it seems just fine:


enter image description here


But in the emulator something is going wrong and here is how it looks strange. What I mean is that the submit button is not on the bottom and the pickDate and pickTime buttons are at the bottom of the layout.


enter image description here enter image description here


I know that I'm missing a basic point here, but as an android developer, I'm not able to spot it.


Can you give me a push?


No comments:

Post a Comment