9

I am pretty sure that a parameter will do the trick but I can't find the one I am looking for.

I am trying to display one TextView -file_type- below the file_title TextView.

What would be the parameter that I should add to the file_type TevxtView block to come under the file_title TextView block ?

There is what I am doing :

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

  <ImageView android:id="@+id/file_type_logo"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="25px"
      android:paddingTop="25px" />

  <TextView android:id="@+id/file_title"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:paddingLeft="30px"
     android:textSize="22sp"
     android:background="#FF0000"
     android:textColor="#FFFFFF" />

  <TextView android:id="@+id/file_type"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:paddingLeft="30px"
     android:paddingTop="10px"
     android:layout_gravity="bottom"
     android:textSize="22sp"
     android:background="#FF0000"
     android:textColor="#FFFFFF" />

</LinearLayout>

Thank you ,

Spredzy
  • 4,982
  • 13
  • 53
  • 69

1 Answers1

27

By default linearlayout wraps things horizontally. If you want the imageview to be at the left of the both textviews (that are wrapped vertically), use following:

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content">

  <ImageView .../>

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

    <TextView1..../>

    <TextView2..../>

 </LinearLayout> 
</LinearLayout>

Or you can just pass the parameter android:orientation="vertical" to the top level LinearLayout. Have a look at RelativeLayout definition as well.

Mika Vatanen
  • 3,782
  • 1
  • 28
  • 33