Reputation: 933
<?xml version="1.0" encoding="utf-8"?>
<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:background="#ffffff"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity" >
<looputill.RoundedImageView
android:id="@+id/login_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loop" />
<EditText
android:id="@+id/login_editUsername"
android:layout_width="226dp"
android:layout_height="45dp"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/top_rounded_white"
android:drawableLeft="@drawable/user_s_icon"
android:drawablePadding="@dimen/margin_10dp"
android:ems="10"
android:gravity="center"
android:hint="Username"
android:padding="@dimen/margin_10dp"
android:textColor="#0060a4"
android:textSize="@dimen/font_18dp" />
<Button
android:id="@+id/signin"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/rounded_blue"
android:padding="@dimen/margin_10dp"
android:text="Sign-In"
android:textColor="#ffffff"
android:textSize="@dimen/font_20dp" />
</LinearLayout>
This is my xml i have to add footer but i unable to add footer in below i am showing screen
desire screen is below
Current screen:
please tell me how to add footer i tried but its not going to bottom i have applied android aliened bottom property not working and also i have to set image view text view bit upper according to desire screen please help .
Upvotes: 0
Views: 82
Reputation: 29
You can divide your Linear Layout into two parts using layout_weight first part should be of 95% and second part should be 5% keeping Oriention vertical of the main Linear Layout. and thn you can achieve your result
Upvotes: -1
Reputation: 2087
try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout 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:background="#ffffff"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity" >
<looputill.RoundedImageView
android:id="@+id/login_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loop" />
<EditText
android:id="@+id/login_editUsername"
android:layout_width="226dp"
android:layout_height="45dp"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/top_rounded_white"
android:drawableLeft="@drawable/user_s_icon"
android:drawablePadding="@dimen/margin_10dp"
android:ems="10"
android:gravity="center"
android:hint="Username"
android:padding="@dimen/margin_10dp"
android:textColor="#0060a4"
android:textSize="@dimen/font_18dp" />
<Button
android:id="@+id/signin"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/rounded_blue"
android:padding="@dimen/margin_10dp"
android:text="Sign-In"
android:textColor="#ffffff"
android:textSize="@dimen/font_20dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/footer_layout"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
Upvotes: -1
Reputation: 28823
You can achieve this using RelativeLayout
. Keep LinearLayout at bottom which contains separator and TextView, or make a separate footer.xml and include it in xml.
<RelativeLayout 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:background="#ffffff"
tools:context=".MainActivity" >
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:gravity="center"
android:orientation="vertical" >
<looputill.RoundedImageView
android:id="@+id/login_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loop" />
<EditText
android:id="@+id/login_editUsername"
android:layout_width="226dp"
android:layout_height="45dp"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/top_rounded_white"
android:drawableLeft="@drawable/user_s_icon"
android:drawablePadding="@dimen/margin_10dp"
android:ems="10"
android:gravity="center"
android:hint="Username"
android:padding="@dimen/margin_10dp"
android:textColor="#0060a4"
android:textSize="@dimen/font_18dp" />
<Button
android:id="@+id/signin"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/rounded_blue"
android:padding="@dimen/margin_10dp"
android:text="Sign-In"
android:textColor="#ffffff"
android:textSize="@dimen/font_20dp" />
</LinearLayout>
<LinearLayout android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="copyright"
layout_gravity="center"/>
</LinearLayout>
</RelativeLayout>
Upvotes: 0
Reputation: 3322
try like this,
<?xml version="1.0" encoding="utf-8"?>
<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:background="#ffffff"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<looputill.RoundedImageView
android:id="@+id/login_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loop" />
<EditText
android:id="@+id/login_editUsername"
android:layout_width="226dp"
android:layout_height="45dp"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/top_rounded_white"
android:drawableLeft="@drawable/user_s_icon"
android:drawablePadding="@dimen/margin_10dp"
android:ems="10"
android:gravity="center"
android:hint="Username"
android:padding="@dimen/margin_10dp"
android:textColor="#0060a4"
android:textSize="@dimen/font_18dp" />
<Button
android:id="@+id/signin"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/rounded_blue"
android:padding="@dimen/margin_10dp"
android:text="Sign-In"
android:textColor="#ffffff"
android:textSize="@dimen/font_20dp" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="copyright"
android:textSize="12sp" />
</LinearLayout>
Upvotes: -1
Reputation: 375
Put the footer widgets in its own layout and give the layout the following property
android:gravity="center|bottom"
then give your TextView or what ever widget you have in the footer the following property
android:layout_gravity="bottom"
Upvotes: 0
Reputation: 231
Create an other layout fotter.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" >
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Your Text"/>
</LinearLayout>
and then include this layout at the end of your main layout like
<include layout="@layout/fotter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
Upvotes: 0
Reputation: 157457
you could use a RelativeLayout with two children. The first is your LinearLayout with android:layout_alignParentTop="true"
, and the second one is the your footer view with attribute android:layout_alignParentBottom="true"
Upvotes: 0