London
London

Reputation: 15284

Put elements in separate lines

I'm trying to put TextView, EdiText, and Button on 3 separate lines but they end up on the same line :

<TextView android:id="@+id/lat_label"
    android:layout_weight="1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:hint="@string/lat_label" />

<EditText android:id="@+id/edit_message"
    android:layout_weight="1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:hint="@string/edit_message" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_send"
    android:onClick="sendMessage" />

I just started android, what do I do ?

Upvotes: 0

Views: 233

Answers (2)

Simon Dorociak
Simon Dorociak

Reputation: 33515

Put elements in seperate lines

You need to use android:orientation="vertical" property for your layout and then you will have element on one line and next element bellow its.

Upvotes: 1

user370305
user370305

Reputation: 109257

Put LinearLayout as a parent to these three view and set android:orientation="vertical" to that LinearLayout. That's it. Simple :-)

Try this..

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

<TextView android:id="@+id/lat_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="@string/lat_label" />

    <EditText android:id="@+id/edit_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send"
        android:onClick="sendMessage" />

</LinearLayout>

Upvotes: 2

Related Questions