Alex Rivera | Logout

Display TextView Bottom of the Screen in Android

Asked 2011-04-21T12:14:14.830
11

In my application, i want to display one TextView in Top of the Screen with screen width. next want to display graphical view below that TextView. next display one Text View below that Graphical View.

I used following xml code. In my code TextView couldnt display in bottom of the screeen.

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

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView  
android:orientation="horizontal"
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello"
android:background="#FF8A11"
android:padding="8dip"
/>
</LinearLayout>



<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<com.game.viewdot.ViewDot
 android:id="@+id/DrawView"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 />   
 </LinearLayout>



 <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom"
android:layout_gravity="bottom"  
>

<TextView  

android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="Another Text View"
android:background="#FF8A11"
android:padding="8dip"
android:gravity="bottom"
 android:layout_gravity="bottom"
/>

</LinearLayout>

What modification i want to put in this code to get my result??????

Edit
Report

1 Answer

8

Instead of using LinearLayout as a parent layout use Relative Layout. Try to use the following code

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

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/relative01"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        android:background="#FF8A11" 
        android:padding="8dip"
        android:id="@+id/textView01"
        />
        <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/textView01"
    >
    <com.game.viewdot.ViewDot
 android:id="@+id/DrawView"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 />   
     </LinearLayout>



     <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_alignParentBottom="true"
    >

    <TextView  

    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Another Text View"
    android:background="#FF8A11"
    android:padding="8dip"

    />

    </LinearLayout>

    </RelativeLayout>

Hope this will help you...:)

answered 2011-04-21T12:32:06.043

Your Answer