Reputation: 933
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??????
Upvotes: 11
Views: 51380
Reputation:
try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_gravity="bottom">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/ContentView"
android:layout_gravity="bottom" android:layout_alignParentBottom="true"/>
</RelativeLayout>
Upvotes: 19
Reputation: 11571
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...:)
Upvotes: 8
Reputation: 33258
set android:layout_height="fill_parent" property for all View expect TextView....
Upvotes: 0