Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1898024
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:42:59+00:00 2026-05-17T06:42:59+00:00

Is there a way to include one resource in another (for example a header

  • 0

Is there a way to include one resource in another (for example a header design in multiple activities’ layouts). I know I can add it at run time, can it be done in the XML?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:42:59+00:00Added an answer on May 17, 2026 at 6:42 am

    Yes you can do this in XML. See the android docs
    about merge/include

    basically you would have 1 layout(root.xml) as follows:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/rootLayout"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
      <LinearLayout
        android:id="@+id/headingLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
          <include
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            layout="@layout/heading_layout" />
      </LinearLayout>
    <RelativeLayout>
    

    and the heading_layout.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <merge
      xmlns:android="http://schemas.android.com/apk/res/android">
        <RelativeLayout
          android:layout_width="fill_parent"
          android:layout_height="wrap_content">
            <ImageView
              android:id="@+id/titleImg"
              android:src="@drawable/bg_cell"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content" />
            <TextView
              android:id="@+id/titleTxt"
              android:layout_centerInParent="true"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" />
        </RelativeLayout>
    </merge>
    

    so in your Activity you would setContentView(R.layout.root); which would include the header.

    you can also do some cool stuff in addition to this programmatically, such as inserting a layout from xml into a the root.xml(after setContentView();:

    LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.home, rootLayout);
    

    where rootLayout is the parent RelativeLayout found by id and R.layout.home is a layout you wish to add to the root

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way I can dynamically include a package based on whatever delegate
Is there way to set @include mixin(); to variable? I tried this @mixin bg-gradient($fallback,
Is there any way to include MySQL expressions like NOW() in the current build
Is there any way to include php file using require and calling a php
Is there a way to include a LIKE expression in a GROUP BY query?
Is there a way to include some aspx/ascx markup in a DLL and use
Is there a way to not be forced to include members with the MustOverride
Is there any way to configure Doxygen to include the log from SVN for
Is there a way for me to include a simple array of strings, or
(Is there a way to | How do I) include a custom description for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.