Alignment of View Elements within a LinearLayout

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2010-02-07T00:39:54Z Indexed on 2010/05/26 17:01 UTC
Read the original article Hit count: 277

Filed under:

I hate to ask this question; for some reason I can't figure it out on my own. I have a vertical LinearLayout that contains a custom View that I've defined in my app and and a TextView. I'd like my custom View to be aligned on the top of the screen and the TextView to be aligned at the bottom of the screen. Unfortunately, no matter what changes I make to the attributes of the XML file, my custom View always seems to be centered vertically when I run the emulator. The xml is like the following:

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:gravity="top">

    <CustomView
     android:id="@+id/customID"
        android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                tileSize="24"
                android:focusableInTouchMode="true" android:layout_gravity="top"/>

    <TextView
     android:id="@+id/text"
        android:text="@string/droidtactoe_layout_text"
        android:visibility="visible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:textSize="24sp" android:textColor="#00000000" android:layout_gravity="bottom"/>

</LinearLayout>

© Stack Overflow or respective owner

Related posts about android