Android : How to make my footer fix to whole the application in android

on Saturday, August 9, 2014


I have made an android app,I am having a menu(footer) at the bottom of all the activities of application,I am including them all in all the activities,It works fine,But when i go to one activity from another activity transition is made also with footer ,So My need is i want it to be fixed at the bottom,and only the activity above it should made transition.Please help me.My xml code for footer menu is as below. menu.xml



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00000000" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#00000000"
android:orientation="horizontal"
android:weightSum="5" >

<RelativeLayout
android:id="@+id/rl_dest"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:background="#D41016" >

<TextView
android:id="@+id/txtDest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:tag="500"
android:text="@string/dest"
android:textColor="#ffffff"
android:textSize="19px" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/rl_new_book"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:background="#D41016" >

<TextView
android:id="@+id/txtnewBook"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="@string/new_buk"
android:textColor="#ffffff"
android:textSize="20px" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/rl_social"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:background="#D41016" >

<TextView
android:id="@+id/txtsocial"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="@string/Social"
android:textColor="#ffffff"
android:textSize="20px" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/rl_view_book"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:background="#D41016" >

<TextView
android:id="@+id/txtviewBooking"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="@string/view_buk"
android:textColor="#ffffff"
android:textSize="20px" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/rl_contact_us"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:background="#D41016" >

<TextView
android:id="@+id/txtviewcontact"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:text="@string/Contact_Us"
android:textColor="#ffffff"
android:textSize="20px" />
</RelativeLayout>
</LinearLayout>

<LinearLayout
android:id="@+id/ll_tb2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:weightSum="5" >

<ImageView
android:id="@+id/llfooterDest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:src="@drawable/destination" />

<ImageView
android:id="@+id/llfooternewbook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:src="@drawable/new_booking" />

<ImageView
android:id="@+id/llfootersocial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:src="@drawable/social_icon" />

<ImageView
android:id="@+id/llfooterviewBook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:src="@drawable/view_booking" />

<ImageView
android:id="@+id/llfootercontact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:src="@drawable/contact_us" />
</LinearLayout>

</RelativeLayout>


menu.java



package com.eps.blancatours.uc;

import javax.crypto.spec.IvParameterSpec;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.eps.blancatours.R;
import com.eps.blancatours.ui.AddBookingpopupActivity;
import com.eps.blancatours.ui.AddDestListActivity;
import com.eps.blancatours.ui.ContactUsActivity;
import com.eps.blancatours.ui.DestinationsActivity;
import com.eps.blancatours.ui.NewBookingActivity;
import com.eps.blancatours.ui.SocialActivity;
import com.eps.blancatours.ui.ViewBookingActivity;

public class Menu extends RelativeLayout implements OnClickListener {

public Context objContext;
// ImageViews.........!
public ImageView llfooterDestinations;
public ImageView llfooterNewBooking = null;
public ImageView llfootersocial = null;
public ImageView llfooterViewBooking = null;
public ImageView llfooterContactUs = null;

// TextViews........!!
public TextView destinations;
public TextView newBooking;
public TextView social;
public TextView viewBooking;
public TextView contactUs;

// RelativeLayouts.........!!!
public RelativeLayout rlDestinations = null;
public RelativeLayout rlNewBooking = null;
public RelativeLayout rlSocial = null;
public RelativeLayout rlViewBooking = null;
public RelativeLayout rlContactUs = null;

public Menu(Context context) {
super(context);
objContext = context;
init();
}

public Menu(final Context context, AttributeSet attrs) {
super(context, attrs);
objContext = context;
init();
}

public void init() {
View view = LayoutInflater.from(objContext).inflate(R.layout.uc_menu,
this, true);

llfooterDestinations = (ImageView) view.findViewById(R.id.llfooterDest);
llfootersocial = (ImageView) view.findViewById(R.id.llfootersocial);
llfooterNewBooking = (ImageView) view
.findViewById(R.id.llfooternewbook);
llfooterViewBooking = (ImageView) view
.findViewById(R.id.llfooterviewBook);
llfooterContactUs = (ImageView) view.findViewById(R.id.llfootercontact);

destinations = (TextView) findViewById(R.id.txtDest);
social = (TextView) findViewById(R.id.txtsocial);
viewBooking = (TextView) findViewById(R.id.txtviewBooking);
newBooking = (TextView) findViewById(R.id.txtnewBook);
contactUs = (TextView) findViewById(R.id.txtviewcontact);

rlDestinations = (RelativeLayout) findViewById(R.id.rl_dest);
rlNewBooking = (RelativeLayout) findViewById(R.id.rl_new_book);
rlSocial = (RelativeLayout) findViewById(R.id.rl_social);
rlViewBooking = (RelativeLayout) findViewById(R.id.rl_view_book);
rlContactUs = (RelativeLayout) findViewById(R.id.rl_contact_us);

rlDestinations.setOnClickListener(this);
rlNewBooking.setOnClickListener(this);
rlSocial.setOnClickListener(this);
rlViewBooking.setOnClickListener(this);
rlContactUs.setOnClickListener(this);
}

@Override
public void onClick(View v) {
// TODO Auto-generated method stub Intent
Intent intent = null;
switch (v.getId()) {
case R.id.rl_dest:
intent = new Intent(objContext, DestinationsActivity.class);
objContext.startActivity(intent);
((Activity) objContext).overridePendingTransition(
R.anim.animated_activity_slide_right_in,
R.anim.animated_activity_slide_left_out);
((Activity) objContext).finish();

break;
case R.id.rl_new_book:
intent = new Intent(objContext, AddDestListActivity.class);
objContext.startActivity(intent);
((Activity) objContext).overridePendingTransition(
R.anim.animated_activity_slide_right_in,
R.anim.animated_activity_slide_left_out);
((Activity) objContext).finish();

break;
case R.id.rl_social:
intent = new Intent(objContext, SocialActivity.class);
objContext.startActivity(intent);
((Activity) objContext).overridePendingTransition(
R.anim.animated_activity_slide_right_in,
R.anim.animated_activity_slide_left_out);
((Activity) objContext).finish();
break;
case R.id.rl_view_book:
intent = new Intent(objContext, ViewBookingActivity.class);
objContext.startActivity(intent);
((Activity) objContext).overridePendingTransition(
R.anim.animated_activity_slide_right_in,
R.anim.animated_activity_slide_left_out);
((Activity) objContext).finish();
break;
case R.id.rl_contact_us:
intent = new Intent(objContext, ContactUsActivity.class);
objContext.startActivity(intent);
((Activity) objContext).overridePendingTransition(
R.anim.animated_activity_slide_right_in,
R.anim.animated_activity_slide_left_out);
((Activity) objContext).finish();
break;
}
}

public void setSelectedTab(int selectTab) {
switch (selectTab) {
case 1:

rlDestinations.setBackgroundResource(R.drawable.hover_img);
llfooterDestinations.setImageResource(R.drawable.destination);

break;
case 2:

rlNewBooking.setBackgroundResource(R.drawable.hover_img);
llfooterNewBooking.setImageResource(R.drawable.new_booking_hover);

break;
case 3:

rlSocial.setBackgroundResource(R.drawable.hover_img);
llfootersocial.setImageResource(R.drawable.social_icon_hover);
break;

case 4:

rlViewBooking.setBackgroundResource(R.drawable.hover_img);
llfooterViewBooking.setImageResource(R.drawable.view_booking_hover);
break;

case 5:

rlContactUs.setBackgroundResource(R.drawable.hover_img);
llfooterContactUs.setImageResource(R.drawable.contact_us_hover);
break;

}
}

}

0 comments:

Post a Comment