Reputation: 15284
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
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
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