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

  • Home
  • SEARCH
  • 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 8987439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:47:35+00:00 2026-06-15T21:47:35+00:00

I want to create a UI layout in XML and have it inserted as

  • 0

I want to create a UI layout in XML and have it inserted as a child into an existing view (It will be inserted multiple times).

For example, here is what the XML file will contain:

<RelativeLayout
    android:id="@+id/relativeLayout1" >
    <Button android:id="@+id/myButton"
        android:text="@string/mystring" />
</RelativeLayout>

Now I get the parent LinearLayout and now want to add that XML file as a child view, e.g:

LinearLayout linear = (LinearLayout) findViewById(R.id.myLayout);

// need to create a view object from the xml file
linear.addView(myXmlObject);

Is it possible to convert an XML resource to a view type? If so, how would I do this?

  • 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-06-15T21:47:37+00:00Added an answer on June 15, 2026 at 9:47 pm

    I believe you want the LayoutInflater. Let’s say your example XML is in a file custom_layout.xml:

    LayoutInflater inflater = LayoutInflater.from(context);
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.custom_layout, null, false);
    
    LinearLayout linear = (LinearLayout)findViewById(R.id.myLayout);
    linear.addView(layout);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the xml layout, and I want to create View from it -
I want to create a layout like below.. This is the XML i have
I want to create a Button otherthan creating it from xml layout.i want to
I want to create a multicolumn layout in html that will run from left
I want to create a XML layout dynamically but I had a question on
I have 2 layout xml files: highlights.xml and highlights_cell.xml. Here is a simplified version
I have to create the Layout (in xml or in java) as like Below
I have a general question regarding Android's separation of layouts into layout.xml files: My
New to android programming. I have a layout XML, to which I want to
I want to create a layout like this for android cellphone app I have

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.