'How do I shift the <include> layout to the bottom of the view
I am trying to push my included view to the bottom of the layout, however I am not having any luck.Currently it's placed at the top of the layout.The code for the same is as follows:
<?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="@color/altercolor2"
android:clickable="true"
android:orientation="vertical" >
<include
layout="@layout/layout_grid_details_header_view"
android:visibility="gone" />
<include layout="@layout/last_updated_time" />
<RelativeLayout
android:id="@+id/markets_column_names"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black"
android:paddingBottom="3dp" >
<TextView
android:id="@+id/markets_column_name1"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/markets_column_name2"
android:textSize="12sp"
android:gravity="right" />
<TextView
android:id="@+id/markets_column_name2"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/markets_column_name3"
android:textSize="12sp"
android:gravity="right" />
<TextView
android:id="@+id/markets_column_name3"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="12sp"
android:paddingRight="6dp"
android:gravity="right" />
</RelativeLayout>
<com.handmark.pulltorefresh.library.PullToRefreshListView
android:id="@+id/markets_grid_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="@layout/loading_no_results" />
</LinearLayout>
The main thing I am looking to switch at the bottom of the list is : <include layout="@layout/last_updated_time" />
so, I tried I also tried setting paddingbottom andlayout_below: relavitive layout id, and tried setting layout_gravity = bottom and gravity = botttom, still no luck.Any clue how to push this at the bottom of the view such that it still remains visible even if the list is long, but at the bottom of the view, like overlapping the list view at the bottom.
Thanks!Justin
Solution 1:[1]
Give layout_width and layout_height attribute to 'include tag', then you can give it any of it's parent tag attribute
Solution 2:[2]
Since the root layout is a LinearLayout with a vertical orientation, it is going to be drawn in the order you have them. Simply putting it as the last View in the xml would draw it below the previous View then you could play with margin, padding, whatever to get it to be where you want.
A better option would be to change the root layout to a RelativeLayout and give the View in question the property
android:layout_alignParentBottom="true
You may have to adjust some properties of other Views to get exactly what you want but its hard to say without seeing an image of how it should look. Also, android:layout_below="" wouldn't work with its parent layout being a LinearLayout...that is only a property for RelativeLayout.
Edit with code 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"
android:background="@color/altercolor2"
android:clickable="true" >
<include
layout="@layout/layout_grid_details_header_view"
android:visibility="gone" />
<include layout="@layout/last_updated_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<RelativeLayout
android:id="@+id/markets_column_names"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black"
android:paddingBottom="3dp" >
<TextView
android:id="@+id/markets_column_name1"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/markets_column_name2"
android:textSize="12sp"
android:gravity="right" />
<TextView
android:id="@+id/markets_column_name2"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/markets_column_name3"
android:textSize="12sp"
android:gravity="right" />
<TextView
android:id="@+id/markets_column_name3"
android:layout_width="85dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="12sp"
android:paddingRight="6dp"
android:gravity="right" />
</RelativeLayout>
<com.handmark.pulltorefresh.library.PullToRefreshListView
android:id="@+id/markets_grid_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="@layout/loading_no_results" />
</RelativeLayout >
Solution 3:[3]
Try using frame layout : make your current linearlayout as first child (removing the include view that u want to move to bottom). Make the include view as second view and set its layout_gravity to bottom.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | |
| Solution 3 | Sukhvir Singh |
