Kevin
Kevin

Reputation: 23634

How to place a text below another text

<LinearLayout
        android:layout_width="0dip"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:layout_weight="1"
        android:clickable="true"
        android:gravity="center_vertical"
        >
        <TextView
            android:id="@+id/f_day_time"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Date/Time"
            android:textColor="#000000"
            android:gravity="left"
            android:paddingLeft="8dp"
             />
        <TextView
            android:id="@+id/f_time"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="#000000"
            android:gravity="left"
            android:paddingLeft="8dp"
             />
    </LinearLayout>

I am trying to place text under a text. inside a linear layout. I don't want a relative layout here as i am placing them inside a ListView.

Upvotes: 0

Views: 75

Answers (2)

stinepike
stinepike

Reputation: 54672

use android:orientation="vertical"

android orientation vertical will place the child of a viewgroup vertically (i.e up down orientation) while orientation horizontal that you used will set the child horizontally (i.e side by side). By default the orientation is horizontal.

Upvotes: 3

Android Developer
Android Developer

Reputation: 1039

android:orientation="vertical"

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

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

Upvotes: 1

Related Questions