I got a screen with several input boxes and at end of it a button, but the button doesn't fit on the screen, as you can see on the image:
How can I get the button under the comment textbox. So when the multiline textbox expands, the button moves down?
EDIT: Here is my xml layout
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
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="be.example.timelogger.NewLogActivity" >
<TextView
android:id="@+id/tvDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="25dp"
android:text="@string/dateText"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tvStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvDate"
android:layout_below="@+id/inputDate"
android:layout_marginTop="22dp"
android:text="@string/startTimeText"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tvEndTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvStartTime"
android:layout_below="@+id/inputStartTime"
android:layout_marginTop="26dp"
android:text="@string/endTimeText"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tvDurationTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/inputEndTime"
android:layout_centerVertical="true"
android:text="@string/durationTimeText"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/inputDate"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tvDate"
android:layout_marginLeft="18dp"
android:layout_toRightOf="@+id/tvDuration"
android:ems="10"
android:inputType="date"
android:onClick="showDatePickerDialog" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/inputEndTime"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/tvEndTime"
android:layout_alignBottom="@+id/tvEndTime"
android:layout_alignLeft="@+id/inputDate"
android:ems="10"
android:inputType="time"
android:onClick="showTimePickerDialogEnd" />
<EditText
android:id="@+id/inputStartTime"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/inputEndTime"
android:layout_alignTop="@+id/tvStartTime"
android:ems="10"
android:inputType="time"
android:onClick="showTimePickerDialogStart" />
<TextView
android:id="@+id/tvDuration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvEndTime"
android:layout_centerVertical="true"
android:text="@string/durationText"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tvCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvDuration"
android:layout_below="@+id/tvDuration"
android:layout_marginTop="30dp"
android:text="@string/tvCourseText"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Spinner
android:id="@+id/spinCourse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/tvCourse"
android:layout_toRightOf="@+id/tvDurationTime" />
<EditText
android:id="@+id/txtComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvComment"
android:layout_alignRight="@+id/inputEndTime"
android:layout_below="@+id/tvComment"
android:layout_marginTop="17dp"
android:ems="10"
android:isScrollContainer="true"
android:inputType="textMultiLine" />
<TextView
android:id="@+id/tvComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvCourse"
android:layout_below="@+id/spinCourse"
android:layout_marginTop="28dp"
android:text="@string/commentText"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="@string/btnSaveText" />
</RelativeLayout>
Use a
ScrollView
so if there are more contents you can scorll. and off course different screen sizes will be handled too. Example:In your code, the problem is that you align the button to parent bottom. Do this instead:
This puts your button below the TextView and you might even don't need the
ScrollView
.