I need to display some text just below title bar has shown below ,few text on left side and few on right side,how to align accordingly.
<?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:background="#android:color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ShowRoom"
android:textColor="#android:color/black"
android:textStyle="bold"/>
</LinearLayout>
I have to us this textview for the entire layout but need to postion one below the other in left left and right side has in image
titlebar.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/titlebar" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
android:weight="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="Showroom" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
android:weight="1" />
</LinearLayout>
activity_text.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="#layout/titlebar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_margin="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="12345617890" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="Ramakrisha Trippp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="9876543210" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1"
android:layout_margin="10dp"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="13/1/2015" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Rohit Sharma" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Add this in your layout before setcontentView to hide your default action bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Related
I am trying to align the express badge to the right of the layout and I need the title to take as much width as possible. This is the code I have right now.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/listPreferredItemHeight"
android:orientation="horizontal"
android:padding="#dimen/margin_large">
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
tools:src="#drawable/ic_download" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:paddingStart="#dimen/margin_large"
android:paddingEnd="#dimen/margin_large">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/title"
style="#style/AppTheme.Text.Light.SemiDarker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Example of title" />
<com.client.presentation.components.ChipView
android:id="#+id/badge"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="#+id/subtitle"
style="#style/AppTheme.Text.Body1.Light"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Example of subtitle" />
</LinearLayout>
</LinearLayout>
The clue is to set weight to 1 in TextView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:minHeight="?attr/listPreferredItemHeight"
android:orientation="horizontal"
android:padding="#dimen/margin_large"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
tools:src="#drawable/ic_angry_android" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:paddingStart="32dp"
android:paddingEnd="32dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/title"
android:layout_weight="1"
style="#style/AppTheme.Text.Light.SemiDarker"
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="Example of title" />
<....
</LinearLayout>
<TextView
android:id="#+id/subtitle"
style="#style/AppTheme.Text.Body1.Light"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Example of subtitle" />
</LinearLayout>
</LinearLayout>
I have a simple LinerLayout with 3 child linear layouts , each have a text view
when Im trying to align the text view to the center or to the right , nothing happens. its always aligned to the left, why ?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_weight="1"
android:id="#+id/alert_type"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="TYPE"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_below="#id/alert_type"
android:id="#+id/alert_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/alert_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="ALERT"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_below="#id/alert_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/alert_details"
android:text="DETAILS" />
</LinearLayout>
</LinearLayout>
you can use RelativeLayout instead
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_weight="1"
android:id="#+id/alert_type"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="TYPE"/>
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_below="#id/alert_type"
android:id="#+id/alert_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/alert_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="ALERT"/>
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_below="#id/alert_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/alert_details"
android:text="DETAILS" />
</RelativeLayout>
</LinearLayout>
or you can use gravity to the linearlayout not textview..like
<LinearLayout
android:layout_weight="1"
android:id="#+id/alert_type"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TYPE"/>
</LinearLayout>
Change android:layout_width="wrap_content" of TextView to match_parent
Set gravity like
android:gravity="center"
You need to set
android:gravity="center"
for each TextView's and LinearLayout.
change layout_width="wrap_content" and layout_gravity="centre"
<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:id="#+id/alert_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1" >
<TextView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="TYPE" />
</LinearLayout>
<LinearLayout
android:id="#+id/alert_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/alert_type"
android:layout_gravity="center"
android:layout_weight="1" >
<TextView
android:id="#+id/alert_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="ALERT" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/alert_layout"
android:layout_gravity="center"
android:layout_weight="1" >
<TextView
android:id="#+id/alert_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DETAILS" />
</LinearLayout>
Use below XML code for your layout, in which I set all textview at center position
<?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:id="#+id/alert_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TYPE" />
</LinearLayout>
<LinearLayout
android:id="#+id/alert_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:id="#+id/alert_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="ALERT" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
android:id="#+id/alert_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DETAILS" />
</LinearLayout>
</LinearLayout>
You just need to add android:gravity="center" in your linear layout. You can also provide any alignment like right, center_vertical etc.
Hi in this Layout i have two button's named as back and home same names i mentioned as id's for both.Now left side i want to display back button and right side corner i want to display home.But home button not displaying at the right corner.Now if i mention margin left it's not showing properly.Can any one please help me
xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#FF0000"
android:orientation="horizontal">
<Button
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
/>
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textStyle="bold"
/>
<Button
android:id="#+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/home"
android:layout_marginLeft="60dp"
/>
</LinearLayout>
</LinearLayout>
Try this,
<?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="30dp"
android:background="#FF0000"
android:orientation="horizontal"
android:weightSum="100" >
<Button
android:id="#+id/back"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="20"
android:background="#drawable/back" />
<TextView
android:id="#+id/tv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:text="Hello"
android:textStyle="bold" />
<Button
android:id="#+id/home"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="60dp"
android:layout_weight="20"
android:background="#drawable/home" />
</LinearLayout>
</LinearLayout>
Try below code xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#FF0000"
android:orientation="horizontal">
<Button
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#drawable/back"
/>
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:textStyle="bold"
/>
<Button
android:id="#+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/home"
android:layout_alignParentRight="true"
android:layout_marginLeft="60dp"
/>
</RelativeLayout>
</LinearLayout>
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#FF0000"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textStyle="bold"/>
</LinearLayout>
<Button
android:id="#+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/home"/>
</LinearLayout>
why don't you use relative layout for that, see that
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#FF0000"
android:orientation="horizontal" >
<Button
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/account_settings" />
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textStyle="bold" />
<Button
android:id="#+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/account_settings"
android:gravity="center_horizontal" />
</RelativeLayout>
</LinearLayout>
if you want to do this with linear layout use weight sum
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#FF0000"
android:weightSum="3"
android:orientation="horizontal" >
<Button
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/account_settings" />
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:textStyle="bold" />
<Button
android:id="#+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_weight="1"
android:background="#drawable/account_settings" />
</LinearLayout>
</LinearLayout>
Below is my gridview layout which works fine and clicks. But when I change my layout it's not clicking any more. Tell me why I just change xml not code. Tell me what is wrong in my xml? Why gridView stopped clicking? is it because of layout weight?
I'm changing from this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/image2"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:padding="5dp"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/title2"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingTop="10dp"
android:textColor="#000" />
</LinearLayout>
To this:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/image2"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_weight="1"
android:gravity="center_horizontal"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:orientation="vertical" >
<TextView
android:id="#+id/title2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="center_vertical"
android:textColor="#000000" />
<TextView
android:id="#+id/title3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical" >
<Button
android:id="#+id/ButtonSendFeedback"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/roundshapebtn"
android:text="Order Now"
android:textColor="#ffffff"
android:textSize="15pt" />
</LinearLayout>
You have some spaces in your layout maybe your click events did not trigger becasue of this. Just use below layout and check if your problem is solved:
<?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:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/image2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#58FA58"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/title2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#DF013A" />
<TextView
android:id="#+id/title3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#2EFEF7" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/ButtonSendFeedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="dummy"/>
</LinearLayout>
See the following XML code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<include layout="#layout/header" />
<TextView
android:layout_width="fill_parent"
android:layout_height="18dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/header"
android:orientation="horizontal" >
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/calendar" />
<TextView
android:id="#+id/tvTitle"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:gravity="center"
android:text="#string/calendar"
android:textColor="#FFFFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/myLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<!-- <include layout="#layout/footer"/> -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/datename_bottom_bg"
android:orientation="horizontal">
<TextView
android:id="#+id/upgrade_4"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"
android:drawableTop="#drawable/upgrade"
android:gravity="center"
android:text="#string/upgrade"
android:textSize="8sp" />
<TextView
android:id="#+id/panchang_4"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"
android:drawableTop="#drawable/kalash_bottom"
android:gravity="center"
android:text="#string/panchang"
android:textSize="8sp" />
<TextView
android:id="#+id/time_range_4"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"
android:drawableTop="#drawable/timer_bottom"
android:gravity="center"
android:text="#string/timespan"
android:textSize="8sp" />
<TextView
android:id="#+id/reminder_4"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"
android:drawableTop="#drawable/reminder_bottom"
android:gravity="center"
android:text="#string/reminders"
android:textSize="8sp" />
<!--
<TextView android:id="#+id/calendar_4" android:layout_width="50dp" android:layout_height="50dp" android:drawableTop="#drawable/calendar_bottom"
android:text="#string/calendar" android:textSize="8sp" android:gravity="center" android:layout_weight="1"/>
-->
</LinearLayout >
</LinearLayout>
</ScrollView>
What this looks like is on the left and what I want it to look like is on the right, I also tried it by replacing LinearLayout to RelativeLaout but still not working. Please Help.!
You should use RelativeLayout, Look for example
<?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" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffff0000"
android:layout_above="#+id/bottom_panel">
</ScrollView>
<LinearLayout
android:id="#+id/bottom_panel"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Button 1"/>
<Button
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Button 2"/>
<Button
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Button 3"/>
<Button
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Button 4"/>
</LinearLayout>
</RelativeLayout>
This will give you something similar. Just place your widgets instead of my buttons.
why dont you just use relative layout as parent layout set the view as alignparentbottom= true.then if really need it you can put a linear layout in the remaining space
You can include your LinearLayout into a FrameLayout and select in your LinearLayout the attribute android:layout_gravity="bottom":
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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="wrap_content"
android:layout_gravity="bottom">
<!--Your LinearLayout content-->
</LinearLayout>
</FrameLayout>
Try relative layout inside which you can add linear layout.
set gravity:bottom to LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical" >
<include layout="#layout/header" />
<TextView
android:layout_width="fill_parent"
android:layout_height="18dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/header"
android:orientation="horizontal" >
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/calendar" />
<TextView
android:id="#+id/tvTitle"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:gravity="center"
android:text="#string/calendar"
android:textColor="#FFFFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/myLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<!-- <include layout="#layout/footer"/> -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/datename_bottom_bg"
android:orientation="horizontal">
<TextView
android:id="#+id/upgrade_4"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"
android:drawableTop="#drawable/upgrade"
android:gravity="center"
android:text="#string/upgrade"
android:textSize="8sp" />
<TextView
android:id="#+id/panchang_4"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"
android:drawableTop="#drawable/kalash_bottom"
android:gravity="center"
android:text="#string/panchang"
android:textSize="8sp" />
<TextView
android:id="#+id/time_range_4"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"
android:drawableTop="#drawable/timer_bottom"
android:gravity="center"
android:text="#string/timespan"
android:textSize="8sp" />
<TextView
android:id="#+id/reminder_4"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_weight="1"
android:drawableTop="#drawable/reminder_bottom"
android:gravity="center"
android:text="#string/reminders"
android:textSize="8sp" />
<!--
<TextView android:id="#+id/calendar_4" android:layout_width="50dp" android:layout_height="50dp" android:drawableTop="#drawable/calendar_bottom"
android:text="#string/calendar" android:textSize="8sp" android:gravity="center" android:layout_weight="1"/>
-->
</LinearLayout >
</LinearLayout>