Corey
Corey

Reputation: 5

Easiest way to re-use layout in multiple activities

I'm trying to use a NavBar (https://i.sstatic.net/WbbBE.jpg) at the bottom of each page/activity. when an image is clicked, it opens a new page. Such as a page containing a countdown timer.

Would the best way to do this be load the navbar layout onto the bottom of a page containing a countdown timer.Or is it possible to just use one navbar layout page that has a mainActivity layout, then load a countdownPage into the main activity layout, upon a button press?

This would be done for 5 different activities/pages.

Upvotes: 0

Views: 108

Answers (1)

jmarkstar
jmarkstar

Reputation: 1335

You could create a bottom layout, then add it on your layout's activities.

Generic Layout my_bottom_layout.xml

<RelativeLayout android:id="@+id/bottom_layout">
  <RecyclerView/>
</RelativeLayout>

Layout's Activities

<RelativeLayout
android:id="@+id/layout_1">

...

<include layout="@layout/my_bottom_layout" />
</RelativeLayout>


<RelativeLayout
android:id="@+id/layout_2">

...

<include layout="@layout/my_bottom_layout" />
</RelativeLayout>

Upvotes: 3

Related Questions