Displaying text in left most position in Relative Layout - android

'My Topic' text is displayed in centre at the top. And below that there is a list.
I want to display a '<Back' text at the left most position on the same line as 'My Topic'. How can i achieve this?
Here is the relevant layout XML:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingLeft="0dp" >
<TextView
android:id="#+id/topic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="My Topic"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:fontFamily="sans-serif" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/topic"
android:layout_margin="0dp"
android:paddingLeft="0dp"
android:divider="#A2B0B0"
android:dividerHeight="0.5dp"
android:choiceMode="singleChoice" >
</ListView>
</RelativeLayout>

replace your layout with this
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingLeft="0dp" >
<RelativeLayout android:id="#+id/relTopic"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/topic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:text="My Topic"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:fontFamily="sans-serif" />
<TextView
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_alignParentLeft="true"
android:text="Back"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:fontFamily="sans-serif" />
</RelativeLayout>
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/relTopic"
android:layout_margin="0dp"
android:paddingLeft="0dp"
android:divider="#A2B0B0"
android:dividerHeight="0.5dp"
android:choiceMode="singleChoice" >
</ListView>
</RelativeLayout>
You can take both textview in single layout and then give its reference to listview android:layout_below="#id/relTopic"

Add Relative layout above listview and put back button align to left and my topics text layout_widht="match parent" with gravity center
Here is layout code
<?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="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/mainLayout"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="< Back" />
<TextView
android:id="#+id/topic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="My Topic"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/mainLayout"
android:layout_margin="0dp"
android:choiceMode="singleChoice"
android:divider="#A2B0B0"
android:dividerHeight="0.5dp"
android:paddingLeft="0dp"></ListView>
</LinearLayout>

<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/topbar">
<TextView
android:id="#+id/back"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="< Back"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:fontFamily="sans-serif" />
<TextView
android:id="#+id/topic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="My Topic"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:fontFamily="sans-serif" />
</RelativeLayout>
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/topbar"
android:layout_margin="0dp"
android:paddingLeft="0dp"
android:divider="#A2B0B0"
android:dividerHeight="0.5dp"
android:choiceMode="singleChoice" >
</ListView>

Below should be the way to go.
<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="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingLeft="0dp">
<TextView
android:id="#+id/topic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="sans-serif"
android:gravity="center_horizontal"
android:text="My Topic"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="#+id/back"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="sans-serif"
android:gravity="left"
android:text="< Back"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</RelativeLayout>
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/topic"
android:layout_margin="0dp"
android:choiceMode="singleChoice"
android:divider="#A2B0B0"
android:dividerHeight="0.5dp"
android:paddingLeft="0dp"></ListView>
</LinearLayout>
I hope it will help

Simply add this code above your "My Topic":
<TextView
android:id="#+id/tvBack"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="< Back"
android:textAppearance="?android:attr/textAppearanceMedium" />
...and set other attributes as you need.

Related

Unable to place view below RecyclerView

I'm having trouble placing an Adview below a RecyclerView. Currently the RecyclerView is taking up the rest of the layout and the Adview isn't being shown. None of the solutions I have found online have solved my issue. Usually layout_weight or layout_below solves the problem but it isn't in this case.
XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#7c7c7c"
android:focusable="true"
android:focusableInTouchMode="true">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relContainer"
android:background="#drawable/bordershadow2"
android:paddingBottom="17dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="10dp" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/recycler_view"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
<RelativeLayout
android:id="#+id/relContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bordershadow"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TableLayout
android:id="#+id/purchaseTableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:layout_alignParentTop="true"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3">
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/typeSpinner"
style="style/Theme.Material"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:entries="#array/type_array"
android:textSize="#dimen/title_size" />
</TableRow>
</TableLayout>
<EditText
android:id="#+id/searchEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/purchaseTableLayout"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'() "
android:hint="Search"
android:imeOptions="actionDone"
android:singleLine="true" />
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/searchEditText"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3.0">
<Spinner
android:id="#+id/sortRaceSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:entries="#array/sort_race_array"
android:textSize="#dimen/title_size" />
<Spinner
android:id="#+id/sortAffinitySpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:entries="#array/sort_affinity_array"
android:textSize="#dimen/title_size" />
<Spinner
android:id="#+id/sortSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:entries="#array/sort_array"
android:textSize="#dimen/title_size" />
</TableRow>
</TableLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
I had a view that needed to be under a recycler view with dynamic size.
meaning that the view supposes to move down as the RecyclerView grew.
my solution was to add paddingBottom to the RecyclerView and then negative marginTop in the same value to the view, it worked perfectly.
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:paddingBottom="48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_marginTop="-48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
I rewrote your layout file, The recycleview is wrapped inside a linearlayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="12dp"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingBottom="20dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="10dp" />
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:background="#000000"
android:layout_height="60dp"
android:layout_below="#+id/wrapper"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
<RelativeLayout
android:id="#+id/relContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/adView"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TableLayout
android:id="#+id/purchaseTableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:layout_alignParentTop="true"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3">
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/typeSpinner"
style="style/Theme.Material"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical" />
</TableRow>
</TableLayout>
<EditText
android:id="#+id/searchEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/purchaseTableLayout"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'() "
android:hint="Search"
android:imeOptions="actionDone"
android:singleLine="true" />
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/searchEditText"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3.0">
<Spinner
android:id="#+id/sortRaceSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"/>
<Spinner
android:id="#+id/sortAffinitySpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"/>
<Spinner
android:id="#+id/sortSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0" />
</TableRow>
</TableLayout>
</RelativeLayout>
The result is as show
If your recycleview content will extend beyond the display height then you should consider dividing your layout into partitions with android:layout_weight.
Update
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/relContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TableLayout
android:id="#+id/purchaseTableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:layout_alignParentTop="true"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3">
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/typeSpinner"
style="style/Theme.Material"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical" />
</TableRow>
</TableLayout>
<EditText
android:id="#+id/searchEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/purchaseTableLayout"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'() "
android:hint="Search"
android:imeOptions="actionDone"
android:singleLine="true" />
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/searchEditText"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3.0">
<Spinner
android:id="#+id/sortRaceSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"/>
<Spinner
android:id="#+id/sortAffinitySpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"/>
<Spinner
android:id="#+id/sortSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0" />
</TableRow>
</TableLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relContainer"
android:background="#color/colorPrimary"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/wrappers"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
</LinearLayout>
Try adding the android:clipToPadding="false" attribute to your RecyclerView.
The official documentation says, about clipToPadding:
Sets whether this ViewGroup will clip its children to its padding and
resize (but not clip) any EdgeEffect to the padded region, if padding
is present.
By default, children are clipped to the padding of their parent
ViewGroup. This clipping behavior is only enabled if padding is
non-zero.
Your XML layout would end up being:
layout.xml
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relContainer"
android:background="#drawable/bordershadow2"
android:clipToPadding="false"
android:paddingBottom="20dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="10dp" />
You can do it other way, put the Adview on the recycler at the bottom and then in the adapter add an empty ViewHolder which will be always your last element, you can use for it an empty layout with the height of Adview.

ExpandableListView expanding over other layout

I have this layout:
<?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">
<LinearLayout android:id="#+id/details" android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:gravity="center"
android:weightSum="1"
android:visibility="visible">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/background" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Header text"
android:id="#+id/textView6"
android:background="#color/background"
android:textColor="#color/textColor"
android:padding="8dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#color/headerBackground"
android:padding="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/textView7"
android:textStyle="bold" />
</LinearLayout>
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/listview_items"
android:divider="#null"
android:dividerHeight="0dp"
android:groupIndicator="#null"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|bottom">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back"
android:id="#+id/buttonBack"
android:layout_weight="1"
android:clickable="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:id="#+id/buttonNext"
android:layout_weight="1"
android:clickable="true" />
</LinearLayout>
</RelativeLayout>
When the expandable listview has a long list of items, it expands over the bottom layout (the buttons layout).
Is there a way to tell the listview to expand up to where the bottom layout starts?
I have made some changes in your XML File.What I did is make your Button Layout android:layout_alignParentBottom="true" and make your details layout as android:layout_above="#+id/button_layout".Hope it will solve your issue.
<?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">
<LinearLayout
android:id="#+id/details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button_layout"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/background"
android:orientation="vertical">
<TextView
android:id="#+id/textView6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/background"
android:padding="8dp"
android:text="Header text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/textColor"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#color/headerBackground"
android:orientation="vertical"
android:padding="8dp">
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
</LinearLayout>
<ExpandableListView
android:id="#+id/listview_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#null"
android:dividerHeight="0dp"
android:groupIndicator="#null"/>
</LinearLayout>
<LinearLayout
android:id="#+id/button_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="horizontal">
<Button
android:id="#+id/buttonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:text="Back"/>
<Button
android:id="#+id/buttonNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:text="Next"/>
</LinearLayout>
</RelativeLayout>

Three children on RelativeLayout does not get place to be shown

I am trying to show four direct children on a Relative Layout where first one is a EdiText (in 'gone' visibility) and second one is LinearLayout with a TextView and ImageView and third is a ListView and fourth is another LinearLayout.
ListView gets over all children. I am posting below the code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollview"
android:background="#drawable/bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.antoinecampbell.gcmdemo.GcmActivity$PlaceholderFragment">
<EditText
android:id="#+id/recepient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:imeOptions="actionSend"
android:inputType="phone"
android:visibility="invisible">
<requestFocus />
</EditText>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/recepient" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:text="Preview"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"/>
<ImageView android:id="#+id/imageShow"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/abs__ic_go"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
</LinearLayout>
<ListView android:id="#+id/listMessages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayout1"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:listSelector="#00000000"
/>
<LinearLayout
android:id="#+id/bottomview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="#+id/listMessages"
android:layout_alignParentBottom="true"
android:visibility="gone"
android:background="#FFFFFF">
<com.rockerhieu.emojicon.EmojiconEditText
android:id="#+id/name_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:layout_weight="1"
android:hint="#string/enter_message_text"
android:imeOptions="actionSend"
android:inputType="text"
android:layout_gravity="center_vertical"
android:visibility="visible"/>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/frameView"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<fragment
android:id="#+id/emojicons"
android:layout_width="match_parent"
android:layout_height="220dp"
class="com.rockerhieu.emojicon.EmojiconsFragment"/>
</LinearLayout>
<ImageButton
android:id="#+id/send_message_button"
android:background="#drawable/angry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:visibility="visible"/>
</LinearLayout>
</RelativeLayout>
Now I tried using LinearLayout with scrollview inside it, it's now not scrolling the listview
<?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="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/recepient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:imeOptions="actionSend"
android:inputType="phone"
android:visibility="invisible">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:text="Preview"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"/>
<ImageView android:id="#+id/imageShow"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/abs__ic_go"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
<ListView android:id="#+id/listMessages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayout1"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:listSelector="#00000000"
/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottomview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="#+id/listMessages"
android:layout_alignParentBottom="true"
android:visibility="visible"
android:background="#FFFFFF">
<com.rockerhieu.emojicon.EmojiconEditText
android:id="#+id/name_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:layout_weight="1"
android:hint="#string/enter_message_text"
android:imeOptions="actionSend"
android:inputType="text"
android:layout_gravity="center_vertical"
android:visibility="visible"/>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/frameView"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<fragment
android:id="#+id/emojicons"
android:layout_width="match_parent"
android:layout_height="220dp"
class="com.rockerhieu.emojicon.EmojiconsFragment"/>
</LinearLayout>
<ImageButton
android:id="#+id/send_message_button"
android:background="#drawable/angry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:visibility="visible"/>
</LinearLayout>
</LinearLayout>
The ListView will go over other elements because you've not given it any relative positions. In a relative layout, every element will be default appear at (0,0) (ie the top left corner of the view) unless it's given a layout_below, layout_alignBottom etc parameter to determine where it's drawn.
So in this case, you 'resumably want the ListView to have android:layout_below="#id/LinearLayout1 and the bottomview similarly android:layout_below="#id/listMessages.
Here is the xml as per your requirement.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center" >
<EditText
android:id="#+id/edNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:inputType="phone"
android:visibility="gone" />
<LinearLayout
android:id="#+id/llLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edNumber"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="linear layout text" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
</LinearLayout>
<ListView
android:id="#+id/lvList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/llBottom"
android:layout_below="#id/llLayout" >
</ListView>
<LinearLayout
android:id="#+id/llBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#ababab"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Bottom Bar text" />
</LinearLayout>
</RelativeLayout>

Using a ScrollView with three LinearLayouts inside

I got a problem with an .xml file of an Android project.
Particularly, I need to have a Scroll View for the major part of the screen a footer underneath.
The ScrollView is the parent of a LinearLayout which keeps three LinearLayouts inside.
The first twos LinearLayout are correctly shown, but the third has never been shown.
I don't understand the reason why it happens: if I put the third LinearLayout in first position, everyone is correctly showed.
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="AppInfo"
android:padding="5dp"
android:id="#+id/bread" />
<HorizontalScrollView
android:id="#+id/horizontal_scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:id="#+id/layout_image_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffffff"
android:gravity="fill_horizontal"
android:layout_gravity="top"
android:id="#+id/attivita_linear"
android:padding="10dp"
android:isScrollContainer="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nome Attività"
android:id="#+id/textView_nome"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="30dp"
android:paddingBottom="35dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Indirizzo: "
android:id="#+id/textView_indirizzo"
android:textSize="20dp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Telefono: "
android:id="#+id/textView_tel"
android:textSize="20dp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email: "
android:id="#+id/textView_email"
android:textSize="20dp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="www: "
android:id="#+id/textView_www"
android:textSize="20dp"
android:textIsSelectable="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Descrizione: "
android:id="#+id/textView_descrizione"
android:textSize="20dp"
android:textIsSelectable="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#000000"
android:gravity="fill_horizontal"
android:layout_gravity="top"
android:id="#+id/attivita_buttons"
android:padding="10dp"
android:isScrollContainer="true">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"
android:background="#drawable/ic_action_call"
android:contentDescription="prova" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/cola">
</FrameLayout>
</RelativeLayout>
</RelativeLayout>
Hope you can help me.
Any answer would be appreciated.
Set above attribute to your scrollview
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" android:above="#+id/footer">
Bottom part of your ScrollView is getting covered by your footer view. Setting your ScrollView above it will let you scroll entire list.
You can also easily done this using LinearLayout .
Note : textSize value is always given "sp" instead of "dp" for this look at this one Link
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="AppInfo"
android:padding="5dp"
android:id="#+id/bread" />
<HorizontalScrollView
android:id="#+id/horizontal_scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:id="#+id/layout_image_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffffff"
android:gravity="fill_horizontal"
android:layout_gravity="top"
android:id="#+id/attivita_linear"
android:padding="10dp"
android:isScrollContainer="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nome Attività"
android:id="#+id/textView_nome"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="30sp"
android:paddingBottom="35dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Indirizzo: "
android:id="#+id/textView_indirizzo"
android:textSize="20sp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Telefono: "
android:id="#+id/textView_tel"
android:textSize="20sp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email: "
android:id="#+id/textView_email"
android:textSize="20sp"
android:textIsSelectable="false"
android:paddingBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="www: "
android:id="#+id/textView_www"
android:textSize="20sp"
android:textIsSelectable="false" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Descrizione: "
android:id="#+id/textView_descrizione"
android:textSize="20sp"
android:textIsSelectable="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#000000"
android:gravity="fill_horizontal"
android:layout_gravity="top"
android:id="#+id/attivita_buttons"
android:padding="10dp"
android:isScrollContainer="true">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"
android:background="#drawable/ic_action_call"
android:contentDescription="prova" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_call"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/cola">
</FrameLayout>
</RelativeLayout>
</LinearLayout>

Android Aligning Element

Im having trouble aligning my button and textbox at the bottom of the page. Also may relative layout messed up. How do I add a view with the current conversation. my Listview is not working. I want to attain a simple design like this
here is my code. Also the grey is overlaying my app and i can't see my listview
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
/>
<RelativeLayout
android:id="#+id/InnerRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="10dp"
android:background="#color/gray"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="5dp" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:inputType="textMultiLine"
android:lines="3"
android:maxLines="3"
android:minLines="1"
android:scrollbars="vertical" />
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="#string/send"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
but my output looks like this
Try this..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.7"
android:gravity="center"
android:inputType="textMultiLine"
android:lines="3"
android:maxLines="3"
android:minLines="1"
android:scrollbars="vertical"/>
<Button
android:id="#+id/send"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.3"
android:gravity="center"
android:text="#string/send" />
</LinearLayout>
</RelativeLayout>
Or
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<Button android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/send" />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:layout_toLeftOf="#+id/send"
android:lines="3"
android:maxLines="3"
android:minLines="1"
android:scrollbars="vertical"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
EDIT:
<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="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false" />
</LinearLayout>
<LinearLayout
android:id="#+id/InnerRelativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/gray" >
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.8"
android:gravity="center"
android:inputType="textMultiLine"
android:lines="3"
android:maxLines="3"
android:minLines="1"
android:scrollbars="vertical" />
<Button
android:id="#+id/send"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:text="#string/send"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
you should put your EditText and Button inside a LinerLayout(horizontal)
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<EditText
android:layout_width="wrap_content" <!-- or give some dimension -->
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:lines="3"
android:maxLines="3"
android:minLines="1"
android:scrollbars="vertical"
/>
<Button android:id="#+id/send"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/send" />
</LinearLayout>
Try below code..
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:inputType="textMultiLine"
android:lines="3"
android:maxLines="3"
android:minLines="1"
android:layout_toLeftOf="#+id/send"
android:scrollbars="vertical" />
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="send" />
</RelativeLayout>
It is looking like this.
use this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<Button android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/send" />
<EditText
android:id="#+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:layout_toLeftOf="#id/send"
android:lines="3"
android:maxLines="3"
android:minLines="1"
android:scrollbars="vertical"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Add a LinearLayout inside your main relative layout, and add your EditText and Button inside that LinearLayout. Don't forgat to add property android:layout_weight="1" to your elements. like this:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:lines="3"
android:maxLines="3"
android:minLines="1"
android:scrollbars="vertical"
android:layout_weight="1"/>
<Button
android:id="#+id/send"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/send" />
</LinearLayout>

Categories

Resources