I was trying to make an interface that allows horizontal texts to be equally space, using layout_weight for responsiveness
So, I tried the code below
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:background="#android:color/darker_gray">
<TextView
android:gravity="center"
android:text="Guest List"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="24sp"
android:background="#android:color/holo_blue_bright"/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white">
<TextView
android:text="Kunal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="24sp"/>
<TextView
android:text="Darling"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="24sp"/>
<TextView
android:text="Shocker"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="24sp"/>
</LinearLayout>
However, all the texts disappear.
So, could anyone please kindly explain to me what happened and how to fix this problem?
Try this,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/darker_gray"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/holo_blue_bright"
android:gravity="center"
android:text="Guest List"
android:textSize="24sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Kunal"
android:textSize="24sp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Darling"
android:textSize="24sp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Shocker"
android:textSize="24sp" />
</LinearLayout>
</LinearLayout>
Using a white background color in the second LinearLayout, you may be trying to see white on white text.
I'd try to add to the TextViews something along:
android:textColor="#android:color/black"
Related
I have a view that works as a footer of each row of recyclerView. What I am trying to achieve is something like this.
The image represents a row of my recyclerView.and each box a different view.
For most of the part it is obvious but I am having issues placing the the view that is represented by the yellow box at the bottom of the row.
I have tried a few different ways for example:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:id="#+id/colored_penal"
android:layout_width="4dp"
android:layout_height="fill_parent"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="128"
android:textSize="24sp"/>
<TextView
android:id="#+id/unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="mtr" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/hospital_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hey, this is a dummy hospital"
android:textSize="18sp" />
<TextView
android:id="#+id/hospital_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/hospital_name"
android:text="At the end of the road" />
<!--This is the yellow box view that I want at the bottom-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="8dp"
android:layout_alignParentBottom="true">
<TextView
android:id="#+id/waiting_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Waiting time: 40 mins"
android:textSize="8sp"
android:layout_weight="1"/>
<TextView
android:id="#+id/travel_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Travel time: 20 mins"
android:textSize="8sp"
android:layout_weight="1"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
I have used alignParentBottom as true yet the view is not getting placed at the bottom of the row. It makes sense that Android squeezes each row to make sure it looks like a recyclerView but than how to put something at the bottom?
I also tried setting up layout_height="fill_parent" and gravity="bottom" for the LinearLayout (yellow view) despite knowing fill_parent is deprecated but it didn't work anyways.
Would appreciate any input helping me achieve this.
I just optimized layout. You need to specify your own View Components and attributes like maxLines or textSizes and etc. Its layout-ready.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
<View
android:layout_width="10dp"
android:layout_height="match_parent"/>
<View
android:layout_width="100dp"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:padding="12dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Title"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Content"/>
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Footer"/>
</LinearLayout>
Good luck there
Emre
This might do what you are looking for
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="128"
android:textSize="24sp" />
<TextView
android:id="#+id/unit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="mtr" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="#+id/hospital_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hey, this is a dummy hospital"
android:textSize="18sp" />
<TextView
android:id="#+id/hospital_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/hospital_name"
android:text="At the end of the road" />
<!--This is the yellow box view that I want at the bottom-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentStart="true"
android:layout_below="#+id/hospital_address">
<TextView
android:id="#+id/waiting_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Waiting time: 40 mins"
android:textSize="8sp" />
<TextView
android:id="#+id/travel_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Travel time: 20 mins"
android:textSize="8sp" />
</LinearLayout>
<View
android:id="#+id/colored_penal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_below="#+id/hospital_address"
android:layout_marginTop="10dp" />
</RelativeLayout>
</LinearLayout>
When i add long text to my TextView in linear layout it takes up all the space, and other views get squeezed. I set layout_width="0" to every view but it did not help. I should also add that this layout is used in RecyclerView.
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100">
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="#+id/lp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Lp"
android:layout_weight="5" />
//this TextView takes all the space if text is long, but it behaves normally if text is short
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="#+id/nazwa"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Końcówka Yankauer do odsysania pola operacyjnego CH 23 (4 otwory boczne) z kontrolą odsysania"
android:layout_weight="20"/>
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="#+id/ilosc"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="#"
android:layout_weight="5" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="#+id/jednostka"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="JM"
android:layout_weight="15" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="#+id/cenaNetto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="C. net."
android:layout_weight="15" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="#+id/wartNetto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="W.net."
android:layout_weight="15" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="#+id/wartVAT"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="VAT"
android:layout_weight="10" />
<TextView
android:textSize="12sp"
android:gravity="center"
android:id="#+id/wartBrutto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="W. brut."
android:layout_weight="15" />
</android.support.v7.widget.LinearLayoutCompat>
Here is a print screen of what breaks in my app link
Please try below link code as a demo I hope you will get your result.
Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/row_my_booking_unit_name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
</TextView>
<TextView
android:id="#+id/row_my_booking_unit_quantity"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
</TextView>
<TextView
android:id="#+id/row_my_booking_unit_amount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
</TextView>
</LinearLayout>
</TableRow>
</TableLayout>
Did you tried this in your TextView?
android:ellipsize="end"
android:maxLines="1"
If you want each textview to occupy same space then you can assign layout_weight=1 for all.
I've seen those CardViews (I'm not sure they're even CardViews) with dividers used in a lot of apps, so I'm guessing there is an easy way to create them.
I wanted to ask how is it exactly done? are those even CardViews?
I couldn't find out more about them because I didn't know the name of the View exactly, so If someone could direct me to an example with code I'd be grateful.
Image example:
You can use this code this may help
<android.support.v7.widget.CardView
android:id="#+id/cardview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_large"
android:layout_marginRight="#dimen/margin_large"
android:elevation="100dp"
card_view:cardBackgroundColor="#android:color/white"
card_view:cardCornerRadius="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:paddingLeft="25dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Conversations" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="30dp"
android:paddingTop="20dp"
android:paddingBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="game" />
...
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
The shown screenshot shows a normal CardView with views as divider in-between.
There is no DividerView or something similar if you searching for something like this. Just use a simple View with a height and a background.
I've something similar in a library of mine. I use this to create the divider:
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/stroke"/>
card_library.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/libraryname"
style="#style/CardTitle"
android:fontFamily="sans-serif-condensed"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"/>
<TextView
android:id="#+id/libraryversion"
style="#style/CardTitle"
android:fontFamily="sans-serif-condensed"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="4dp"
android:gravity="left|bottom"
android:maxLines="1"
android:textSize="12sp"/>
<TextView
android:id="#+id/librarycreator"
style="#style/CardTitle"
android:fontFamily="sans-serif-condensed"
android:textStyle="normal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:gravity="right"
android:maxLines="2"
android:textSize="14sp"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="4dp"
android:background="#color/stroke"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="4dp">
<TextView
android:id="#+id/description"
style="#style/CardText"
android:fontFamily="sans-serif-condensed"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:maxLines="20">
</TextView>
</LinearLayout>
</LinearLayout>
It will then look like this:
Set app:cardElevation="0dp" then use a View - see below
<android.support.v7.widget.CardView
android:id="#+id/cv"
xmlns:android="http://schemas.android.com/apk/res/android"
app:cardElevation="0dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- Insert UI elements -->
<View
android:layout_width="fill_parent"
android:background="#android:color/darker_gray"
android:layout_height="2dp"/>
</android.support.v7.widget.CardView>
I have the following multiple-column layout on my app:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mcare="http://schemas.android.com/apk/res/com.vodafone.mCare"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3" >
<LinearLayout
android:id="#+id/container1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/label1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello world" />
</LinearLayout>
<LinearLayout
android:id="#+id/container2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/label2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hi" />
<LinearLayout
android:id="#+id/container3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/label3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hi" />
</LinearLayout>
...etc...
</LinearLayout>
All the columns are supposed to be evenly-spaced when enough space is available.
The goal here is to force container1's (and only container1's) minimum width to match the same width of its child view (label1). All the other columns should be resized evenly throughout the rest of the available space, regardless of whether there is enough space to display their contents or not. Here's a rough diagram of what I'm trying to do:
I've tried a lot of different approaches but nothing seems to work so far. Any ideas? Thanks in advance for any suggestion.
Edit: Note that the layout above is just a simplified version of the actual layout on the application. All containers actually have more that one View inside them - with the exception of container1. In other words, only label1 can be moved outside its respective container.
Remove nested TextView inside LinearLayout.
Try like this:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<TextView
android:id="#+id/label1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:background="#android:color/holo_red_light"
android:text="Hello world" />
<TextView
android:id="#+id/label2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:background="#android:color/holo_red_light"
android:text="Hi" />
<TextView
android:id="#+id/label3"
android:layout_width="0dp"
android:gravity="center_horizontal"
android:background="#android:color/holo_red_light"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hi" />
</LinearLayout>
********Edited Answer*************
I have try it with `TextView` inside `LinearLayout` as well, it's working fine:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/label1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:background="#android:color/holo_red_light"
android:text="Hello world" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/label2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:background="#android:color/holo_red_light"
android:text="Hi" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/label3"
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:background="#android:color/holo_red_light"
android:layout_height="wrap_content"
android:text="Hi" />
</LinearLayout>
</LinearLayout>
Without your full XML file we can't help you.
I'm having an issue with my EditText (with id of body) not filling up the available space in my layout. I've been searching everywhere and experimenting with numerous resources, but I just simply can not seem to get it and have been spending hours on literally just this.. I'm guessing there is an issue with how my entire layout is set up, and probably can't just make a tweak in EditText. By the way this layout is being used in a fragment, maybe that changes things? I'm not sure, what do you guys think? Thanks for any and all help! Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title" />
<EditText android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1" >
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/body" />
<EditText
android:id="#+id/body"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:hint="write those saucy lyrics"
android:layout_marginTop="5dp"
android:scrollbars="vertical" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/confirm"
android:text="#string/confirm"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/btnEmail"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/btnEmail"
android:alpha="1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I'm looking for my design to look like this (taken from my graphical layout editor):
However on my device it looks like this(snapshot from my device):
Try this..
Change android:layout_height="wrap_content" to android:layout_height="0dp"
<EditText
android:id="#+id/body"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="vertical" />
// try this way,hope this will help you...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/title"/>
<EditText
android:id="#+id/body"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:hint="#string/body"
android:layout_marginTop="5dp"
android:scrollbars="vertical" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/confirm"
android:text="#string/confirm"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/btnEmail"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="#string/btnEmail"
android:alpha="1" />
</LinearLayout>
</LinearLayout>
Make
android:layout_height="match_parent"
instead of
android:layout_height="wrap_content"
in Body edit text
So that it becomes
<EditText
android:id="#+id/body"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:scrollbars="vertical" />
UPDATE:
Plz try following layout
<!-- Put the buttons at the bottom -->
<RelativeLayout
android:id="#+id/rel_lay_btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Confirm" />
<Button
android:id="#+id/btnEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:alpha="1"
android:text="Emial" />
</RelativeLayout>
<!-- Put the title layout at the top of parent -->
<LinearLayout
android:id="#+id/lin_lay_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentTop="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<EditText
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<!-- Occupy rest of the space of screen -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_above="#id/rel_lay_btn"
android:layout_below="#id/lin_lay_title">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Body" />
<EditText
android:id="#+id/body"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="top"
android:layout_weight="1"
android:scrollbars="vertical" />
</LinearLayout>