How to place Relative Layout at the bottom always - android

MY XMl code looks like :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="430dp"
android:fadingEdge="none"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/descriptionanth"
android:orientation="vertical"
android:id="#+id/searchjobslayout"
>
<ImageView android:id="#+id/homeimage_one" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_width="fill_parent" android:background="#drawable/logoblack"></ImageView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="match_parent">
<TextView
android:id="#+id/keywords"
android:text="Search by keyword:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#000000"
android:layout_marginLeft="10dp"
></TextView>
<EditText
android:id="#+id/keywordsedit"
android:hint=" Enter KeyWords"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="14sp"
android:background="#drawable/text_field"
android:layout_marginTop="5dp"
android:textColorHint="#FFFFFF"
android:paddingLeft="10dp"
android:textColor="#000000"
></EditText>
<Button
android:id="#+id/search"
android:text="Search"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:textColor="#FFFFFF"
android:background="#drawable/buttonclick"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:textSize="20sp"
></Button>
<TextView
android:id="#+id/browseby"
android:text="Browse by:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#000000"
android:layout_marginLeft="10dp"
android:paddingTop="10dp"></TextView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button
android:id="#+id/jobsbycity"
android:text="City"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:textColor="#FFFFFF"
android:background="#drawable/buttonclick"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:textStyle="bold"
android:textSize="15sp"
></Button>
<Button
android:id="#+id/jobsbytype"
android:text="Category"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:textColor="#FFFFFF"
android:background="#drawable/buttonclick"
android:layout_below="#id/jobsbycity"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textStyle="bold"
android:layout_marginTop="5dp"
android:textSize="15sp"
></Button>
<TextView
android:id="#+id/signin"
android:text="Signed in as"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textColor="#000000"
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:layout_below="#id/jobsbytype"
android:paddingTop="10dp"></TextView>
<TextView
android:id="#+id/signinas"
android:text="mail_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_centerInParent="true"
android:textColor="#000000"
android:gravity="center_horizontal"
android:layout_below="#id/signin"
android:paddingTop="5dp"></TextView>
<TextView
android:id="#+id/logout"
android:text="Sign out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:gravity="center_vertical"
android:textColor="#000000"
android:layout_below="#id/signinas"
android:layout_centerInParent="true"
android:layout_marginTop="20dp"
android:textStyle="bold" ></TextView>
</RelativeLayout>
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/tabbarbottom"
android:layout_gravity="bottom"
>
<Button
android:id="#+id/jobs"
android:text="About Us"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:textColor="#drawable/white"
android:background="#android:color/transparent"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:textSize="12.5sp"
></Button>
<Button
android:id="#+id/aboutus"
android:text="Value"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:textColor="#drawable/white"
android:layout_toRightOf="#id/jobs"
android:background="#android:color/transparent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="10dp"
android:textStyle="bold"
android:textSize="12.5sp"
></Button>
<Button
android:id="#+id/benefits"
android:text="History"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#drawable/white"
android:layout_toRightOf="#id/aboutus"
android:background="#android:color/transparent"
android:layout_centerVertical="true"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:textSize="12.5sp"
></Button>
</RelativeLayout>
</LinearLayout>
I want to place the relative layout (last relative layout which having 3 buttons it, after scrollview ) at the bottom my screen. but its not happening
what to do??
Edited: The happening is i statically placed the relative layout by specifying padding, when running in portrait mode i made it fix at bottom but when i changed to landscape its not at bottom. How to place relativelayout in bottom in either cases??
Thanks

Add following line to your Relative layout
android:layout_alignParentBottom="true"
This must be work.
Happy coding.

Here the solution I tested and which works :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="100dp"
android:layout_weight="1.0" android:fadingEdge="none">
...
</ScrollView>
<RelativeLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="60dip"
android:background="#drawable/tabbarbottom">
<Button android:id="#+id/jobs" android:text="About Us"
android:layout_width="100dp" android:layout_height="fill_parent"
...></Button>
<Button android:id="#+id/aboutus" android:text="Value"
android:layout_width="100dp" android:layout_height="fill_parent"
...></Button>
<Button android:id="#+id/benefits" android:text="History"
android:layout_width="fill_parent" android:layout_height="fill_parent" ...></Button>
</RelativeLayout>
</LinearLayout>
The first LinearLayout should have layout_height="fill_parent".
This way it takes up the whole screen.
The ScrollView should have a
small fixed height, and an extra android:layout_weight="1.0" : it
will take up whatever space is remaining.
The RelativeLayout should
have a fixed height (it will always take up the same space at the
bottom of the screen), and the Buttons inside of it should have
layout_height="fill_parent" (to have the same height as the
RelativeLayout).

Make parent layout as relative layout. layout which contain button put that on bottom using
android:layout_alignParentBottom="true"
This will work

In the ScrollView
android:fillViewport="false"

#Udaykiran Hey Your Code for XMl is ok please check here i put your code with some change and i found only one change in this Relative Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
please change this than try
here is xml with with out resources
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="430dp"
android:fadingEdge="none">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:background="#drawable/splash_screen_large_long_land"
android:orientation="vertical" android:id="#+id/searchjobslayout">
<ImageView android:id="#+id/homeimage_one"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:layout_width="fill_parent"></ImageView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:id="#+id/keywords" android:text="Search by keyword:"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="14sp" android:textStyle="bold" android:textColor="#000000"
android:layout_marginLeft="10dp"></TextView>
<EditText android:id="#+id/keywordsedit" android:hint=" Enter KeyWords"
android:layout_width="fill_parent" android:layout_height="32dp"
android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:textSize="14sp" android:layout_marginTop="5dp"
android:textColorHint="#FFFFFF" android:paddingLeft="10dp"
android:textColor="#000000"></EditText>
<Button android:id="#+id/search" android:text="Search"
android:layout_width="fill_parent" android:layout_height="35dp"
android:textColor="#FFFFFF" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginTop="5dp"
android:textSize="20sp"></Button>
<TextView android:id="#+id/browseby" android:text="Browse by:"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="14sp" android:textStyle="bold" android:textColor="#000000"
android:layout_marginLeft="10dp" android:paddingTop="10dp"></TextView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:id="#+id/jobsbycity" android:text="City"
android:layout_width="fill_parent" android:layout_height="30dp"
android:textColor="#FFFFFF" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginTop="5dp"
android:textStyle="bold" android:textSize="15sp"></Button>
<Button android:id="#+id/jobsbytype" android:text="Category"
android:layout_width="fill_parent" android:layout_height="30dp"
android:textColor="#FFFFFF" android:layout_below="#id/jobsbycity"
android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:textStyle="bold" android:layout_marginTop="5dp"
android:textSize="15sp"></Button>
<TextView android:id="#+id/signin" android:text="Signed in as"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="12sp" android:textColor="#000000"
android:layout_centerInParent="true" android:gravity="center_horizontal"
android:layout_below="#id/jobsbytype" android:paddingTop="10dp"></TextView>
<TextView android:id="#+id/signinas" android:text="mail_id"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="12sp" android:layout_centerInParent="true"
android:textColor="#000000" android:gravity="center_horizontal"
android:layout_below="#id/signin" android:paddingTop="5dp"></TextView>
<TextView android:id="#+id/logout" android:text="Sign out"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="13sp" android:gravity="center_vertical"
android:textColor="#000000" android:layout_below="#id/signinas"
android:layout_centerInParent="true" android:layout_marginTop="20dp"
android:textStyle="bold"></TextView>
</RelativeLayout>
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_gravity="bottom">
<Button android:id="#+id/jobs" android:text="About Us"
android:layout_width="100dp" android:layout_height="fill_parent"
android:background="#android:color/transparent"
android:layout_alignParentBottom="true" android:textStyle="bold"
android:textSize="12.5sp"></Button>
<Button android:id="#+id/aboutus" android:text="Value"
android:layout_width="100dp" android:layout_height="fill_parent"
android:layout_toRightOf="#id/jobs" android:background="#android:color/transparent"
android:layout_centerHorizontal="true" android:layout_centerVertical="true"
android:layout_alignParentBottom="true" android:layout_marginLeft="10dp"
android:textStyle="bold" android:textSize="12.5sp"></Button>
<Button android:id="#+id/benefits" android:text="History"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_toRightOf="#id/aboutus" android:background="#android:color/transparent"
android:layout_centerVertical="true"
android:layout_alignParentBottom="true" android:textStyle="bold"
android:textSize="12.5sp"></Button>
</RelativeLayout>

Related

Scrollview issue in xml, doesn't work

I have a following code.. I want to scroll my text area and my buttons within in LinearLayout. But my bottom button which is in relativelayout i want to stay it always in bottom not scroll able.
Thanks
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="175dip"
android:background="#android:color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="20dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="55dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="75dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="95dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="115dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="135dp"
android:textSize="15dip"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="155dp"
android:textSize="15dip"
/>
</RelativeLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Contact Us"/>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="#android:color/black"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/buttonCheck"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:background="#drawable/round_button"
android:text="Checked" />
</RelativeLayout>
</RelativeLayout>
As you are using relative layout, first put the button at the bottom of screen, and then let scrollview occupy the the height available.
Try following code:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="#+id/rel_btn_Check"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:background="#android:color/black" >
<Button
android:id="#+id/buttonCheck"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/round_button"
android:text="Checked" />
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/rel_btn_Check"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="175dip"
android:background="#android:color/white" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="20dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="35dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="55dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="75dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="95dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="115dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="135dp"
android:textSize="15dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="155dp"
android:textSize="15dip" />
</RelativeLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="XYZ" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Contact Us" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
</RelativeLayout>
use this mechanism
set scroll view >
android:layout_weight="1"
and put footer :
android:layout_alignParentBottom="true"
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1">
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="jgfhrtuioghju oioupotyuhjipouipoi typ[ipo[ip[ijup0[ip0[ujiptjuip[juip[i]]]]]]] jogi5thjuohuortthjuo90uto okithjoitthjuo thjpo ktjhporyjohj ptlhjyjohjpy plthjoyjpokjotjhojuyojuhoithjoi kgjhoithoithjuotjupojutpo[ujotpotpojuote]ihihoihoi rguigreuighreiuyghir orighoihyheiyhreiygh oighoihtgihidrfyh8irfyhuesghuyhuiehvguyh rueighuyghuiyghieryhirgeyhi gorfihoihklrjegoij5oi hi thkoihioghoirhirhuiurg] th5yj u trjuykyu yjytku yktyu k ykj k y jiyku ykj yuk yku k y 6ty 6y 6yy kuiil 6 u67 uokityy7 i78o8 "/>
</ScrollView>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"><Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="rgfjughtih g5yujhoihuoi"/></LinearLayout></LinearLayout>

How to align ImageView & TextView align right in a Linear Layout

I would like show my Page view header like below,
I'm using the following layout using, but the image and second textview not moving to right, its all align center.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="6"
android:background="#drawable/transbg"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="6"
android:gravity="center"
>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/yellow2" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</TableRow>
</LinearLayout>
</LinearLayout>
how I can align one image view and textview right aligned.
Check out this one and let me know if it is what you want.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="#android:color/black"
android:gravity="center" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/ic_launcher"
android:layout_toLeftOf="#+id/tvCredits" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
</TableRow>
</LinearLayout>
EDIT : If you want to make the same layout with easier and more efficient way, you can use this one.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/black" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/tvCredits"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
// try this way
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtName"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:gravity="center"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:textColor="#fff"
android:textSize="16sp"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="right">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="6"
android:background="#drawable/transbg"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="6"
android:gravity="center"
>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="right|center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/yellow2" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</TableRow>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Aligning TextViews in RelativeLayout in FrameLayout

I am using a RelativeLayout in a FrameLayout, but I can't seem to get the alignment right. Here is a picture of what I am trying to achieve. Any help is appreciated, thank you!
And here is my current XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="15dp"
android:paddingBottom="15dp" >
<ImageView
android:id="#+id/imgDealImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="#string/dealImage" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/txtDealDesc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="24sp"
android:textColor="#fff"
android:paddingLeft="10dp"
android:background="#80999999" />
<TextView
android:id="#+id/txtSupporters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txtDealDesc"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#e6e600"
android:paddingLeft="10dp" />
<TextView
android:id="#+id/txtRegularPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/txtSupporters"
android:layout_toRightOf="#id/txtSupporters"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#888"
android:paddingBottom="20dp" />
<TextView
android:id="#+id/txtDealPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/txtRegularPrice"
android:layout_toRightOf="#id/txtRegularPrice"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#01a05f" />
</RelativeLayout>
</FrameLayout>
EDIT: ANSWER
I played around with it a little bit and found out that it was my ImageView that was set to wrap_content which should have been fill_parent. Thanks for all your input guys!
Try This:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="15dp"
android:paddingBottom="15dp" >
<ImageView
android:id="#+id/imgDealImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/txtDealDesc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="24sp"
android:textColor="#fff"
android:paddingLeft="10dp"
android:background="#80999999"
android:text="1" />
<TextView
android:id="#+id/txtSupporters"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#e6e600"
android:paddingLeft="10dp"
android:layout_centerInParent="true"
android:text="2" />
<TextView
android:id="#+id/txtRegularPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#888"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="3" />
<TextView
android:id="#+id/txtDealPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#01a05f"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="4" />
</RelativeLayout>
</FrameLayout>
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout android:id="#+id/LinearLayout02" android:layout_height="wrap_content" android:layout_width="match_parent">
<TextView android:id="#+id/Button04" android:text="Button" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"></TextView>
<TextView android:id="#+id/Button05" android:text="Button" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"></TextView>
<TextView android:id="#+id/Button06" android:text="Button" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"></TextView>
</LinearLayout>
<ImageView
android:layout_width="fill_parent"
android:layout_height="223dp"
android:id="#+id/imageView" android:layout_gravity="center_vertical"/>
<LinearLayout android:id="#+id/LinearLayout02"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true" >
<TextView android:id="#+id/Button04" android:text="Button" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"></TextView>
<TextView android:id="#+id/Button06" android:text="Button" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content"></TextView>
</LinearLayout>
</RelativeLayout>

How to fill the layout to entire available width in Android

While developing a layout today I found some weird thing my Linear layout is not filling the available space .
//Image removed
My left layout is re-sizing according to content but i don't want that. What I want is the right edge of left hand side layout should touch the left edge of right layout.
I have tried both fill parent and wrap content with layout_weight but nothing is happening what i want is something like this.
// Image removed
My layout 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="match_parent"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingLeft="7dp"
android:paddingRight="7dp">
<RelativeLayout
android:id="#+id/total_top_layout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingBottom="10dp"
android:layout_centerHorizontal="true">
<TextView
android:id="#+id/ammount_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="First Text Here"
android:textSize="20sp"
android:layout_centerVertical="true" />
<EditText
android:id="#+id/total_ammount_input"
android:layout_height="wrap_content"
android:layout_width="150dp"
android:singleLine="true"
android:layout_alignParentRight="true"
android:background="#color/hologreennewdark"
android:text="second Text"
android:layout_centerVertical="true"
android:padding="8dp"
android:gravity="center"
android:textColor="#color/WhiteSmoke" />
</RelativeLayout>
<View
android:id="#+id/divideaftertotal"
android:layout_width="#dimen/divide_width"
android:layout_height="#dimen/divider_height"
android:background="#color/YellowGreen"
android:layout_below="#+id/total_top_layout"
/>
<RelativeLayout
android:id="#+id/tens_view_top"
android:layout_below="#id/divideaftertotal"
android:layout_height="75dp"
android:layout_width="wrap_content"
>
<LinearLayout
android:id="#+id/tens_view_left"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
>
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Num1"
android:layout_centerVertical="true"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_toRightOf="#id/amount_rupee"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Num2"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_toRightOf="#+id/multiply_sign"
android:layout_marginLeft="40dp" />
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#color/hologreendark"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/divideaftertens"
android:layout_width="#dimen/divide_width"
android:layout_height="#dimen/divider_height"
android:background="#color/YellowGreen"
android:layout_below="#+id/tens_view_top"
/>
</RelativeLayout>
On the layout android:id="#+id/tens_view_left", you could add this 2 atributes:
android:layout_alignParentLeft="true"
so that its left side is anchored in its parent's left border, and
android:layout_toLeftOf="#id/id_from_the_linear_layout_on_the_right"
And that layout is:
<LinearLayout
android:id="#+id/id_from_the_linear_layout_on_the_right"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#color/hologreendark"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
By the way, you might need to set android:orientation="horizontal"
on the layout android:id="#+id/tens_view_top"
When using layout_weight, set the layout_width to 0dp (for horizontal orientation).
it could be like,
<LinearLayout
android:id="#+id/tens_view_left"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
>
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="horizontal"
>
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="0dp"
android:orientation="vertical"
android:layout_weight="1">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Num1"
android:layout_centerVertical="true"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_toRightOf="#id/amount_rupee"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Num2"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_toRightOf="#+id/multiply_sign"
android:layout_marginLeft="40dp" />
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"
/>
</LinearLayout>
<LinearLayout
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#color/hologreendark"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Change the RelativeLayout to LinearLayout that contain two layout you want to have close, and add layout_weight=1 to first LinearLayout with layout_width=0dip like
<LinearLayout
android:id="#+id/tens_view_top"
android:layout_below="#id/divideaftertotal"
android:layout_height="75dp"
android:layout_width="wrap_content"
>
<LinearLayout
android:layout_weight="1"
android:id="#+id/tens_view_left"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="0dip"
>
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Num1"
android:layout_centerVertical="true"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_toRightOf="#id/amount_rupee"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Num2"
android:layout_centerVertical="true"
android:textSize="25sp"
android:layout_toRightOf="#+id/multiply_sign"
android:layout_marginLeft="40dp" />
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="100dp"
android:layout_width="wrap_content"
android:background="#FFCCDD"
android:layout_alignParentRight="true">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="fill_parent"
android:layout_width="100dp"
android:text="Num3"
android:layout_centerVertical="true"
android:textSize="25sp"
android:gravity="center"
/>
</LinearLayout>
// try this i have used LinearLayout rather than RelativeLayout
<?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"
android:padding="7dp">
<LinearLayout
android:id="#+id/total_top_layout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:paddingBottom="10dp">
<TextView
android:id="#+id/ammount_view"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"
android:text="First Text Here"
android:textSize="20sp"/>
<EditText
android:id="#+id/total_ammount_input"
android:layout_height="wrap_content"
android:layout_width="150dp"
android:singleLine="true"
android:text="second Text"
android:padding="8dp"
android:gravity="center"/>
</LinearLayout>
<View
android:id="#+id/divideaftertotal"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<LinearLayout
android:id="#+id/tens_view_left"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:id="#+id/firstcoloumn"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<LinearLayout
android:layout_height="match_parent"
android:gravity="center"
android:layout_width="0dp"
android:layout_weight="1">
<TextView
android:id="#+id/amount_rupee"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="Num1"
android:textSize="25sp" />
<TextView
android:id="#+id/multiply_sign"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="X"
android:layout_centerVertical="true"
android:textSize="26sp"
android:layout_marginLeft="40dp" />
<TextView
android:id="#+id/multiple_digit"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:text="Num2"
android:textSize="25sp"
android:layout_marginLeft="40dp" />
</LinearLayout>
</LinearLayout>
<SeekBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="#+id/multiple_digit"
android:layout_marginTop="8dp"/>
</LinearLayout>
<TextView
android:id="#+id/amount_rupee"
android:layout_height="match_parent"
android:layout_width="100dp"
android:text="Num3"
android:textSize="25sp"
android:gravity="center"/>
</LinearLayout>
<View
android:id="#+id/divideaftertens"
android:layout_width="match_parent"
android:layout_height="1dp"/>
</LinearLayout>

ListView in android should come in whole screen and other elements in the bottom

There is a list view and other text views in my screen.
I want to show the list in whole the screen and other elements in the bottom of the list.
Below is the code I used.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/header1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#layout/header_gradients"
android:orientation="vertical"
android:paddingBottom="8dip"
android:paddingTop="8dip" >
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginLeft="10dip"
android:layout_weight="1"
android:gravity="center"
android:text="#string/shopping_cart"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="5dip"
android:background="#color/white"
android:orientation="horizontal"
android:padding="5dp" >
<TextView
android:id="#+id/purchase_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="2dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/requisitioner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/purchase_order"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:text="Requisitioner"
android:textColor="#color/black"
android:textSize="15sp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:contentDescription="#string/image"
android:src="#drawable/shopping_cart" />
</RelativeLayout>
<TextView
android:id="#+id/products_and_services"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/products_and_services"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/lr1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.12" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/pagingPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/lr1"
android:background="#drawable/background_light_blue"
android:orientation="vertical" >
<TextView
android:id="#+id/note_to_approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="#string/note_to_approver"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="#+id/note"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:background="#color/white"
android:maxLines="10"
android:padding="5dp"
android:text="hijnjn"
android:textColor="#color/black"
android:textSize="15sp"
android:typeface="sans" />
<TextView
android:id="#+id/approver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="15dp"
android:gravity="center_horizontal"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="17sp"
android:textStyle="bold" />
<Button
android:id="#+id/approvers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/options_menu"
android:drawableRight="#drawable/arrow_right"
android:gravity="left|center"
android:text="#string/approvers"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#layout/btn_background" >
<Button
android:id="#+id/release_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#drawable/btn_blue"
android:text="Approve(1)/Reject(0)"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
My requirement: Now the list is scrolling within the given area. I want to show in the whole screen and the scrolling should be only for the screen.
Please help me to do this.
You should not put a Vertically scrolling widget/view (ListView) in another vertically scrolling view (ScrollView). Though there are a few ways mentioned here and here which might help you achieve what you wish but that will increase the CPU load.

Categories

Resources