• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Why my TextView is not coming at the bottom of the screen ?

ramesh_bh

Newbie
Sep 16, 2010
17
1
HI, i want to put a textview at the bottom of my screen, if i implement the code with layout.xml it is working fine.
But if i want to implement the same code with activity.java it is not coming at the bottom. here are my layout.xml and my activity.java files, please help and let me know where could i done mistake ?
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent" android:paddingTop="10dp">
    <LinearLayout android:orientation="horizontal"
        android:id="@+id/footer_linear_view" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_alignParentBottom="true">
        <TextView android:text="Hello Namasthe" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
    </LinearLayout>
</RelativeLayout>

my Activity code :
Code:
        rLayout = new RelativeLayout(this);
        lLayout = new LinearLayout(this);
        texView  = new TextView(this);
        
        rLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
        android.widget.RelativeLayout.LayoutParams tParams = new android.widget.RelativeLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams.FILL_PARENT,android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
        tParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); 
        lLayout.setLayoutParams(tParams);
        texView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
        texView.setText("Subhodayam");
        lLayout.addView(texView);
        rLayout.addView(lLayout);
        setContentView(rLayout);
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones