0

I have the following XML layout.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:padding="6dip" >

    <TextView
        android:id="@+id/itemNumber"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="6dip"
        android:textSize="50px"/>

    <TextView
        android:id="@+id/secondLine"
        android:layout_width="fill_parent"
        android:layout_height="26dip"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_toRightOf="@id/itemNumber"
        android:ellipsize="marquee"
        android:singleLine="true"
        android:textSize="12sp" />

    <TextView
        android:id="@+id/firstLine"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/secondLine"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_alignWithParentIfMissing="true"
        android:layout_toRightOf="@id/itemNumber"
        android:gravity="center_vertical"
        android:textSize="16sp" />

    <RelativeLayout 
        android:id="@+id/InnerRelativeLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <Button 
            android:text="Submit" 
            android:id="@+id/Button"
            android:layout_alignParentRight="true" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </Button>

        <EditText 
            android:id="@+id/EditText" 
            android:layout_width="fill_parent"
            android:layout_toLeftOf="@id/Button"
            android:layout_height="wrap_content">
        </EditText>

    </RelativeLayout>

</RelativeLayout>

What i need to do is make the Edit Text & the Button to appear in the bottom of the screen. I'm using the 3 Text Views to appear as a List View. So i can choose one from the list and enter it into the Edit Text to submit the value.

But I cannot make 'em appear in the bottom. How can i do this?

Msk
  • 857
  • 9
  • 16
k9yosh
  • 858
  • 1
  • 11
  • 31

2 Answers2

2

Replace

    android:layout_height="?android:attr/listPreferredItemHeight"

With

    android:layout_height="match_parent"

// Take a look at this layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="textView 1" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="textView 2" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="textView 3" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal" >

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="submit" />
    </LinearLayout>

</RelativeLayout>
A.R.
  • 2,631
  • 1
  • 19
  • 22
  • It worked, Thank you... But I need to have those 3 Text Views at the Top. Now Those 3 has stretched up to the bottom. Any suggestions? – k9yosh Apr 17 '15 at 18:45
  • How you want to align your textviews vertically or horizontally. – A.R. Apr 17 '15 at 18:50
  • Take a Header view @k9yosh....check my answer and ..you have to just put a header layout ..nd in scrollview container put this android:layout_below="@id/header" > – Tufan Apr 17 '15 at 18:51
  • @k9yosh, I have updated my answer if you don't mind you can try this layout it looks exactly what you want(If i am not wrong). You just need to modify according to your requirement. – A.R. Apr 17 '15 at 19:00
0

just add thie line of code :

android:gravity="bottom"

Edit : more easy to change the second layout to : LinearLayout

Ahmad Ebrahimi
  • 267
  • 5
  • 24