简体   繁体   中英

Easiest way to re-use layout in multiple activities

I'm trying to use a NavBar ( http://imgur.com/a/fygH3 ) 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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM