views:

274

answers:

1

I can't call setContentView to show XML layouts - I can only get a RelativeLayout which I can programmatically modify. Now, what I need to do is add a simple TextView, aligned at the bottom of that RelativeLayout. With XML it would be as simple as:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" 
    android:maxLines="5"
    android:scrollbars="vertical"
    android:text="some text"
    />
</RelativeLayout>

I've been trying various ways of doing this with code, but I can't get it working right. I've tried textView.setGravity(Gravity.BOTTOM) and relativeLayout.setVerticalGravity(RelativeLayout.ALIGN_PARENT_BOTTOM), but those didn't work. I am able to push it down by giving it padding, but I don't want it to fill the whole screen.