Reputation: 1528
I have LinearLayout that save in a separate file and use it with Include
.
The problem is that i want this layout at the bottom of screen. its fine in my first layout that i use RelativeLayout in it . but in the second layout i used LinearLayout and it seems android:layout_alignParentBottom="true"
doesnt work in it. how can i fix this ?
Here is my code:
Included layout:
`
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/lytButtons"
style="@style/Register.LayoutButtons"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dp">
.
.
.
.
</LinearLayout>`
In first layout i have RelativeLayout and in the second one i have LinearLayout. How can i change my included part that keep it at the bottom in both of RelativeLayout and LinearLayout?
Upvotes: 0
Views: 197
Reputation:
to solve your confusion i am giving you sample code to add footer
Footer layout:footer_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.test.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Footer Layout" />
</LinearLayout>
Just simple textview to show as footer .
Main Layout:activity_main.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="horizontal" >
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
layout="@layout/footer_layout" />
</LinearLayout>
Output:
Let me know still any query.
Upvotes: 1
Reputation: 5287
Whenever you want to include this layout in a parent layout, just specify where it should go :
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
layout="@layout/yourLayout" />
EDIT following Piyush Gupta comment : if the parent layout is going to be a linearLayout, just replace the alignParentBottom :
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
layout="@layout/yourLayout" />
Upvotes: 1