How do i place a line between two linearlayouts horizontally? I tried with a additional linearlayout and a one time with a View. My linearlayouts looks currently like this:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
>
<LinearLayout
android:id="#+id/about"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:gravity="start"
android:layout_gravity="start"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
>
<ImageView
android:id="#+id/about_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginStart="20dp"
android:layout_gravity="start|center_vertical"
android:src="#drawable/ic_info_black_24dp"
android:clickable="false"
/>
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_gravity="start|center_vertical"
android:text="About"
android:textSize="20sp"
android:textColor="#android:color/black"
android:clickable="false"
/>
</LinearLayout>
<!--<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_weight="2"
android:elevation="0dp"
android:background="#android:color/black"
/>-->
<LinearLayout
android:id="#+id/theme"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
android:layout_weight="3"
android:gravity="end"
android:layout_gravity="end"
android:background="?android:attr/selectableItemBackground"
>
<ImageView
android:id="#+id/theme_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginEnd="10dp"
android:layout_gravity="end|center_vertical"
android:src="#drawable/ic_palette_white_24dp"
android:tint="#android:color/black"
android:clickable="false"
/>
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_marginEnd="20dp"
android:text="Theme"
android:textSize="20sp"
android:textColor="#android:color/black"
android:clickable="false"
/>
</LinearLayout>
</LinearLayout>
It looks currently like this(the layout on the right side, is a bit more left, dont understand why ^^):
Any suggestions?
Why not use a RelativeLayout and avoid weights all together. Try this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:orientation="horizontal"
xmlns:android="http://schemas.android.com/apk/res/android">
<View
android:id="#+id/divider"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:elevation="0dp"
android:background="#android:color/black" />
<LinearLayout
android:id="#+id/about"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:layout_toLeftOf="#id/divider"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="#+id/about_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginStart="20dp"
android:layout_gravity="start|center_vertical"
android:src="#drawable/ic_launcher"
android:clickable="false"
/>
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_gravity="start|center_vertical"
android:text="About"
android:textSize="20sp"
android:textColor="#android:color/black"
android:clickable="false"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/theme"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:layout_toRightOf="#id/divider"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="#+id/theme_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_marginEnd="10dp"
android:layout_gravity="end|center_vertical"
android:src="#drawable/ic_launcher"
android:tint="#android:color/black"
android:clickable="false"
/>
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical"
android:layout_marginEnd="20dp"
android:text="Theme"
android:textSize="20sp"
android:textColor="#android:color/black"
android:clickable="false"
/>
</LinearLayout>
Get rid of the weights and use a Relative layout to hold your linear layouts. Then add this in your XML:
<View android:id="#+id/separator"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"/>
Then in the layout you want to the right add this line:
android:layout_toRightOf="#+id/separator"
And then for the layout to the left:
android:layout_toLeftOf="#+id/separator"
Related
I have problems with word cutting at XML, look at the picture below:
As you can see word Delete is cut. Below is my layout for this part:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="end"
android:orientation="horizontal"
android:weightSum="30"
android:baselineAligned="false">
<RelativeLayout
android:id="#+id/more_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="10"
android:background="#color/gray_light"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<ImageView
android:id="#+id/pict_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/ic_more"
android:drawablePadding="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="More"
android:layout_below="#id/pict_1"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/archive"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="10"
android:background="#color/colorAccent"
android:paddingStart="5dp"
android:paddingEnd="5dp">
<ImageView
android:id="#+id/pict_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/ic_inbox"
android:contentDescription="TODO" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Archive"
android:layout_below="#id/pict_2"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/delete"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="10"
android:background="#FF0000"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<ImageView
android:id="#+id/pict_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/ic_delete"
android:drawablePadding="10dp" />
<TextView
android:layout_below="#id/pict_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
android:textAlignment="viewStart"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
In general I noticed that it is caused by padding which pull elements inside parent layout. I tried to change it, but I see that word Archive is also can be influenced. How I can solve this problem with wrong layout xml?
add you third layout(delete) with wrap content and weight like below
<RelativeLayout
android:id="#+id/delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="10"
android:background="#FF0000"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<ImageView
android:id="#+id/pict_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/ic_delete"
android:drawablePadding="10dp" />
<TextView
android:layout_below="#id/pict_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
android:textAlignment="viewStart"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
I have two views side by side inside a relative layout. I want the format of both views to be like the one on the left ("Today's Special"). I've assigned both views the same attributes though they are different.
here is my xml.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="ExtraText">
<RelativeLayout
android:id="#+id/view_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/bg_row_background">
<ImageView
android:id="#+id/delete_icon"
android:layout_width="#dimen/ic_delete"
android:layout_height="#dimen/ic_delete"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="#dimen/padd_10"
android:contentDescription="#string/deleteIcon"
android:src="#drawable/ic_delete_white_24dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="#dimen/padd_10"
android:layout_toStartOf="#id/delete_icon"
android:text="#string/delete"
android:textColor="#fff"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/view_foreground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:padding="#dimen/padd_5">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="#dimen/ic_delete"
android:background="#color/description"
android:textColor="#color/item_name"
android:textSize="12sp" />
<TextView
android:id="#+id/namecat"
android:layout_width="wrap_content"
android:layout_height="#dimen/ic_delete"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#id/name"
android:background="#color/description"
android:paddingStart="#dimen/padd_10"
android:textColor="#color/item_name"
android:textSize="12sp" />
</RelativeLayout>
</FrameLayout>
Thanks for your help.
Replace FrameLayout with LinearLayout and weightsum property
<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="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
tools:ignore="ExtraText">
<RelativeLayout
android:id="#+id/view_background"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#978c8c">
<ImageView
android:id="#+id/delete_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_lock" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="#id/delete_icon"
android:text="#string/dummy_button"
android:textColor="#fff"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/view_foreground"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#android:color/white">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:background="#color/colorAccent"
android:textColor="#color/colorPrimary"
android:textSize="12sp" />
<TextView
android:id="#+id/namecat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#id/name"
android:background="#color/colorAccent"
android:textColor="#color/colorPrimaryDark"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
I am not able to align the footer at the Bottom of the screen.I have used RelativeLayout within which android:layout_alignParentBottom="true" but the layout is not displayed at the bottom of the screen.
loan_collection_layout
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="#layout/appbar_layout" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:background="#156B7A"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="125dp"
android:text="Branch Office : Dhankuta"
android:textColor="#FFFFFF"
android:textSize="10sp" />
<View
android:layout_width="1dp"
android:layout_height="13dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:text="Tuesday -4 April,2017"
android:textColor="#FFFFFF"
android:textSize="10sp"
/>
</LinearLayout>
<!-- Loan collection -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Loan Collection"
android:textColor="#2493A7"
android:textSize="15sp"
android:textStyle="bold" />
<ImageView
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_gravity="center"
android:layout_marginLeft="120dp"
android:layout_marginRight="2dp"
android:src="#mipmap/filter" />
<TextView
android:layout_width="wrap_content"
android:layout_height="15dp"
android:layout_gravity="center"
android:text="Filter"
android:textSize="12sp"
android:textStyle="normal" />
<View
android:layout_width="1dp"
android:layout_height="15dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="#98A6A9" />
<ImageView
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="0.01"
android:src="#mipmap/search" />
<TextView
android:layout_width="wrap_content"
android:layout_height="15dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:text="Search"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
<!-- Linear Layout for 2nd Linear Layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<!-- 2nd liner layout ist column -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="12dp"
android:layout_gravity="center"
android:layout_marginTop="7dp"
android:src="#mipmap/center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Center:005"
android:textSize="10sp" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.03"
android:background="#FFFFFF" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="12dp"
android:layout_gravity="center"
android:layout_marginTop="7dp"
android:src="#mipmap/group" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Group"
android:textSize="10sp" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.03"
android:background="#FFFFFF" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="12dp"
android:layout_gravity="center"
android:layout_marginTop="7dp"
android:src="#mipmap/loan_type" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Loan Type"
android:textSize="10sp" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.03"
android:background="#FFFFFF" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="12dp"
android:layout_gravity="center"
android:layout_marginTop="7dp"
android:src="#mipmap/date" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Date:"
android:textSize="10sp" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.03"
android:background="#FFFFFF" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="12dp"
android:layout_gravity="center"
android:layout_marginTop="7dp"
android:src="#mipmap/valuedate" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="value date:"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout> <!-- Linear Layout 2nd ends Here -->
<!-- Linear Layout for Group code starts here-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<CheckBox
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginRight="5dp"
android:buttonTint="#000000" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Group Code"
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Member No."
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Member Name"
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Remain Price"
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Total"
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<!-- 3rd layout starts here -->
<!-- After third layout you have yo add listView in here and listitem should be populated through the JSON Data -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<CheckBox
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginRight="5dp"
android:buttonTint="#333333"
android:checked="true" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#F3F3F3">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="001"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#F3F3F3">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text=" 001"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#F3F3F3">
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Bimala Rai"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#F3F3F3">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="0.00"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#F3F3F3">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="0.00"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout><!-- 3rd layout ends here-->
<!-- Linear Layout 4th starts here-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<CheckBox
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginRight="5dp"
android:buttonTint="#333333" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="001"
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="001"
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="Uranus"
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="0.00"
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/border_loan_collection">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="0.00"
android:textColor="#333333"
android:textSize="12sp"
android:textStyle="normal" />
</LinearLayout>
</LinearLayout> <!-- 4th linear layout ends here -->
<!-- Total Bottom Layout starts herel -->
<!-- Footer aligned to bottom -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_alignParentBottom="true"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
How can footer be displayed at bottom of screen??
You main view is LinearLayout which does not works the way you are trying it to.
For obtaining your desired result you need your main Layout to be Relative layout and then set align bottom true to your footer.
For eg:-
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- place all your view inside this layout-->
</LinearLayout>
<!--place your footer here with align bottom property set to true-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_alignParentBottom="true"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout/>
This snippet should get you going.
You have two options, either follow #Anirudh Sharma's answer, or just make your RelativeLayout's height to match_parent.
Your parent linear layout will stack your views in the orientation you have provided in your layout in order, one after the other. android:layout_alignParentBottom="true" would work only for views defined inside a RelativeLayout and not in the way you have defined.
Make your parent layout as RelativeLayout instead of LinearLayout and it would work perfectly for you!
Add following just above your footer
<View
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp" />
The problem is AlignParentBottom only works when the view is inside a Relative Layout. Your Textview is inside a Linear Layout.Put it outside of the Linear Layout and Inside the parent Relative Layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="#layout/appbar_layout" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:background="#156B7A"
android:orientation="horizontal">
.
.
.
.
</LinearLayout>
<!-- Make sure your View is directly the child of Relative layout to use
alignParentBottom="true" -->
<!-- Footer aligned to bottom -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_alignParentBottom="true"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
try this:
<RelativeLayout
android:id="#+id/rl"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#6AED83"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Footer"
android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Try below code, it will work
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="1">
//Your other code will be here
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Footer"
android:layout_gravity="center"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
Whatever you want in footer make sure you write code inside main parent layout(Relative layout) so u sill set android:layout_alignParentBottom="true"
and it will remain all the time
.Note that write that code just above the </RelativeLayout> (Closing of main parent layout ). So footer never get hidden by any other layout.
I currently have 4 ImageButtons in a layout that takes only half of the screen height. I would like the ImageButtons to be placed evenly in the layout. Here is what I have:
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"
android:layout_weight="1" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"
android:layout_weight="1" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
This works, since here is the result:
The issue is, 1: I would like to add text under each button and I am not sure how that is going to work and 2: the white spots to the right and left of the ImageButtons are active, as if they were parts of the button. Is there a better way to do this?
You can do something like this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/section1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img1"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="info 1"
android:textColor="#fff"
android:textSize="25sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/img2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img2"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="info 2"
android:textColor="#fff"
android:textSize="25sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/img3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img3"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="info 3"
android:textColor="#fff"
android:textSize="25sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/img4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:src="#mipmap/ic_launcher" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img4"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="info 4"
android:textColor="#fff"
android:textSize="25sp" />
</RelativeLayout>
</LinearLayout>
Result
and for second part of question you should set click listener on entire relative layout. for example for tap on first cell :-
xml
android:id="#+id/section1"
JAVA
findviewbyid(R.id.section1).setOnClickListener(...)
Another (and better) alternative is to work with TableLayout:
<?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:stretchColumns="1">
<TableRow
android:layout_height="0dp"
android:layout_weight="1">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/btn1"
android:contentDescription="#null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"/>
<TextView
android:id="#+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn1"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:text="Text 1"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/btn2"
android:contentDescription="#null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"/>
<TextView
android:id="#+id/txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn2"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:text="Text 2"/>
</RelativeLayout>
</TableRow>
<TableRow
android:layout_height="0dp"
android:layout_weight="1">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/btn3"
android:contentDescription="#null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"/>
<TextView
android:id="#+id/txt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn3"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:text="Text 3"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/transparent">
<ImageButton
android:id="#+id/btn4"
android:contentDescription="#null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#mipmap/feed_button"
android:background="#android:color/transparent"/>
<TextView
android:id="#+id/txt4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/btn4"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:text="Text 4"/>
</RelativeLayout>
</TableRow>
</TableLayout>
I am having an issue with android phones having a bottom action bar where the app screen is being cut off by the action bar in the phone. Please see the screenshot below which better describes my issue. The button is being cut off by the actionbar.
Below is my layout xml file.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#mipmap/main_bg"
tools:context="com.myapp.SeatsActivity">
<RelativeLayout
android:id="#+id/actionbar_layout"
android:layout_width="match_parent"
android:layout_height="#dimen/irctc_actionbar_height"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView4"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="6dp"
android:onClick="onClickgoHome"
android:src="#mipmap/iconhome" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="4dp"
android:layout_toLeftOf="#+id/button11"
android:layout_toRightOf="#+id/imageView4"
android:gravity="center"
android:text="SEAT AVAILABILITY"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="#dimen/irctc_actionbar_height"
android:layout_height="#dimen/irctc_actionbar_height"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/trans_button"
android:clickable="true"
android:onClick="onClickShare"
android:padding="4dp"
android:scaleType="fitCenter"
android:src="#mipmap/share" />
<Button
android:id="#+id/button11"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/imageView5"
android:onClick="onClickDate"
android:text="date:"
android:textColor="#color/white" />
</RelativeLayout>
<LinearLayout
android:id="#+id/horizontal_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/actionbar_layout"
android:background="#color/white"
android:orientation="vertical" />
<TextView
android:id="#+id/txtview_trainname"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_below="#+id/horizontal_line"
android:background="#color/irctc_menu_bg_color"
android:gravity="center"
android:text="Train Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/hr2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/txtview_trainname"
android:background="#color/white"
android:orientation="vertical" />
<TextView
android:id="#+id/txtview_fromtostation"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_below="#+id/hr2"
android:background="#color/irctc_menu_bg_color"
android:gravity="center"
android:text="Station Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/hr3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/txtview_fromtostation"
android:background="#color/white"
android:orientation="vertical" />
<LinearLayout
android:id="#+id/layout_table_header"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_below="#+id/hr3"
android:background="#color/irctc_menu_bg_color"
android:orientation="horizontal">
<TextView
android:id="#+id/textView6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:gravity="center"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/txtview_class1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center"
android:text="class1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/txtview_class2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center"
android:text="class2"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="#+id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_above="#+id/btn_express_book"
android:layout_alignParentBottom="false"
android:background="#color/irctc_menu_bg_color">
<TextView
android:id="#+id/textView9"
android:layout_width="70dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="Quota:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_quota"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/imageView9"
android:layout_toRightOf="#+id/textView9"
android:background="#drawable/trans_button"
android:onClick="onClickQuota"
android:text="Selected Quota"
android:textColor="#color/white" />
<ImageView
android:id="#+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="#drawable/trans_button"
android:clickable="true"
android:onClick="onClickTrainSchedule"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:scaleType="fitCenter"
android:src="#mipmap/train_schedule" />
<ImageView
android:id="#+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/imageView8"
android:background="#drawable/trans_button"
android:clickable="true"
android:onClick="onClickFareEnquery"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:scaleType="fitCenter"
android:src="#mipmap/fair_enquiry" />
</RelativeLayout>
<ListView
android:id="#+id/listview_seatcell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/adView"
android:layout_below="#+id/layout_table_header" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/layout_bottom"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id" />
<Button
android:id="#+id/btn_express_book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:background="#drawable/irctc_button"
android:onClick="onClickExpressBook"
android:paddingBottom="10dp"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:text="Express Book!"
android:textColor="#ffffff" />
</RelativeLayout>
Am I doing something wrong here? What changes would I need to make to the xml to accommodate phones with an action bar ?
I've already add ScrollView to your ViewGroup. Check it:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#mipmap/main_bg"
tools:context="com.myapp.SeatsActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
<RelativeLayout
android:id="#+id/actionbar_layout"
android:layout_width="match_parent"
android:layout_height="#dimen/irctc_actionbar_height"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView4"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="6dp"
android:onClick="onClickgoHome"
android:src="#mipmap/iconhome" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="4dp"
android:layout_toLeftOf="#+id/button11"
android:layout_toRightOf="#+id/imageView4"
android:gravity="center"
android:text="SEAT AVAILABILITY"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="#dimen/irctc_actionbar_height"
android:layout_height="#dimen/irctc_actionbar_height"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/trans_button"
android:clickable="true"
android:onClick="onClickShare"
android:padding="4dp"
android:scaleType="fitCenter"
android:src="#mipmap/share" />
<Button
android:id="#+id/button11"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/imageView5"
android:onClick="onClickDate"
android:text="date:"
android:textColor="#color/white" />
</RelativeLayout>
<LinearLayout
android:id="#+id/horizontal_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/actionbar_layout"
android:background="#color/white"
android:orientation="vertical" />
<TextView
android:id="#+id/txtview_trainname"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_below="#+id/horizontal_line"
android:background="#color/irctc_menu_bg_color"
android:gravity="center"
android:text="Train Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/hr2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/txtview_trainname"
android:background="#color/white"
android:orientation="vertical" />
<TextView
android:id="#+id/txtview_fromtostation"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_below="#+id/hr2"
android:background="#color/irctc_menu_bg_color"
android:gravity="center"
android:text="Station Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/hr3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/txtview_fromtostation"
android:background="#color/white"
android:orientation="vertical" />
<LinearLayout
android:id="#+id/layout_table_header"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_below="#+id/hr3"
android:background="#color/irctc_menu_bg_color"
android:orientation="horizontal">
<TextView
android:id="#+id/textView6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:gravity="center"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/txtview_class1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center"
android:text="class1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/txtview_class2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:gravity="center"
android:text="class2"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="#+id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_above="#+id/btn_express_book"
android:layout_alignParentBottom="false"
android:background="#color/irctc_menu_bg_color">
<TextView
android:id="#+id/textView9"
android:layout_width="70dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="Quota:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_quota"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/imageView9"
android:layout_toRightOf="#+id/textView9"
android:background="#drawable/trans_button"
android:onClick="onClickQuota"
android:text="Selected Quota"
android:textColor="#color/white" />
<ImageView
android:id="#+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="#drawable/trans_button"
android:clickable="true"
android:onClick="onClickTrainSchedule"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:scaleType="fitCenter"
android:src="#mipmap/train_schedule" />
<ImageView
android:id="#+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/imageView8"
android:background="#drawable/trans_button"
android:clickable="true"
android:onClick="onClickFareEnquery"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:scaleType="fitCenter"
android:src="#mipmap/fair_enquiry" />
</RelativeLayout>
<ListView
android:id="#+id/listview_seatcell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/adView"
android:layout_below="#+id/layout_table_header" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/layout_bottom"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id" />
<Button
android:id="#+id/btn_express_book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:background="#drawable/irctc_button"
android:onClick="onClickExpressBook"
android:paddingBottom="10dp"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:text="Express Book!"
android:textColor="#ffffff" />
</RelativeLayout>
</ScrollView>
Hope it help
Try Setting android:layout_alignParentBottom="false" to android:layout_alignParentBottom="true" inside of the layout. So something like this.
<RelativeLayout
android:id="#+id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_above="#+id/btn_express_book"
android:layout_alignParentBottom="true"
android:background="#color/irctc_menu_bg_color">
Don't use RelativeLayout to imitate LinearLayout.
None of your views overlap, and none of them need need any kind of special alignment with other views. Recreating that with layout_below and layout_above is confusing. Everything you have in your layout can be done with LinearLayouts instead and will be much clearer, except for maybe the two action bars (but even those might be possible with LinearLayouts too).
Don't use empty LinearLayouts as horizontal dividers.
If you have to use a view at all, just use View. But if you are doing this inside of a LinearLayout as I suggest in #1, then you might not need views at all, you could use
android:showDividers="middle"
android:divider="#drawable/hr"
and in res/drawable/hr.xml
<shape android:shape="rectangle">
<size android:height="1dp" />
<solid android:color="#android:color/white" />
</shape>
Don't ever use wrap_content as the height of a ListView.
ListView doesn't know anything about its children. Telling it to be as tall as it needs to contain them doesn't make any sense, and ListView is just going to try to guess. You should always use either a static value, match_parent, or allow it to fill some arbitrary space using layout_weight (if using LinearLayout) or other view boundaries (if using `RelativeLayout).
Combining all of the above, I think your layout should end up looking like this (only the relevant parts are shown):
<LinearLayout android:orientation="vertical" ...>
<RelativeLayout ... /> <!-- Top action bar -->
<TextView ... />
<TextView ... />
<LinearLayout android:orientation="horizontal" ... /> <!-- table header -->
<ListView
android:layout_height="0dp"
android:layout_weight="1"
... />
<AdView ... />
<RelativeLayout ... /> <!-- bottom action bar -->
<Button ... /> <!-- The one that is currently cut off -->
</LinearLayout>