Arjun Issar
Arjun Issar

Reputation: 654

Common View through Activities

I need to create multiple activities that will have a bar at the bottom of the screen. This bar contains three functions that are common to the activities. Can i keep the bar constantly on screen and switch through activities?

One way could be to load different fragments on the same activity, and let the bar be below the fragments.

But is it possible to switch between activities, without recreating the bar every time a new activity opens?

Upvotes: 0

Views: 260

Answers (2)

Gagan Sethi
Gagan Sethi

Reputation: 407

Possible option:

  1. You have to create bottom layout bottomlayout.xml

    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">
    
    
    <TextView
        android:id="@+id/toolBarText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="2dp"
        android:background="@android:color/transparent"
        android:layout_centerInParent="true"
        android:text="TOOLBAR TEXT"
        android:textColor="#FFFFFF"
        android:textSize="15dp" />
    </RelativeLayout>
    
  2. Include bottomlayout in every xml layout of activity.

    <include layout="@layout/bottomlayout"/>
    

Upvotes: 1

Arjun Issar
Arjun Issar

Reputation: 654

Fragments, is one way of doing it. Isn't there any other.

Upvotes: 0

Related Questions