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 6935681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:08:04+00:00 2026-05-27T12:08:04+00:00

Can we Manipulate the Xml layout in our Java code . I mean Lets

  • 0

Can we Manipulate the Xml layout in our Java code . I mean Lets say i have a layout in Xml and a want to create its object and change its properties (say adding some child before passing it to setcontentveiw() method)

public class IconExtensionLayoutActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    RelativeLayout mcontainer = (RelativeLayout)IconExtensionLayoutActivity.this.findViewById(R.id.mContainerIconExtension);
    ScrollView mScrollView = (ScrollView)IconExtensionLayoutActivity.this.findViewById(R.id.mRootIconExtension);
    RelativeLayout mRow1 = (RelativeLayout)IconExtensionLayoutActivity.this.findViewById(R.id.Root_Layout_Iconset_One_ID);
    RelativeLayout mRow2 = (RelativeLayout)IconExtensionLayoutActivity.this.findViewById(R.id.Root_Layout_Iconset_Two_ID);
    RelativeLayout mRow3 = (RelativeLayout)IconExtensionLayoutActivity.this.findViewById(R.id.Root_Layout_Iconset_Three_ID);

    setContentView(mScrollView.getId());

}

}

and My Xml layout is below.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mContainerIconExtension"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:scrollbars="none" >

    <RelativeLayout
        android:id="@+id/Root_Layout_Iconset_One_ID"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/IconSet_One_ID"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:src="@drawable/ic_launcher" >
        </ImageView>

        <RelativeLayout
            android:id="@+id/IconSet_One_ScrollView_ID"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/IconSet_One_ID"
            android:layout_margin="5dip" >

            <HorizontalScrollView
                android:id="@+id/HorizontalScrollView02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:scrollbarAlwaysDrawHorizontalTrack="false"
                android:scrollbars="none" >

                <LinearLayout
                    android:id="@+id/LinearLayout03"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <ImageView
                        android:id="@+id/ImageView20"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView19"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView21"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView22"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView23"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView24"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView25"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView31"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView32"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView05"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView02"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView01"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView04"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView03"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView06"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>
                </LinearLayout>
            </HorizontalScrollView>
        </RelativeLayout>

        <ImageView
            android:id="@+id/PURCHASE_BUTTON_ICONSET_1_ID"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/IconSet_One_ScrollView_ID"
            android:src="@drawable/ic_launcher" >
        </ImageView>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/Root_Layout_Iconset_Two_ID"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/ImageView17"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:src="@drawable/ic_launcher" >
        </ImageView>

        <RelativeLayout
            android:id="@+id/RelativeLayout02"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/ImageView17"
            android:layout_margin="5dip" >

            <HorizontalScrollView
                android:id="@+id/Horizontal_Scroller"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scrollbars="none" >

                <LinearLayout
                    android:id="@+id/LinearLayout01"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <ImageView
                        android:id="@+id/ImageView51"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView50"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView49"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView48"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView47"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView46"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView45"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView44"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView43"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView40"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView39"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView38"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView37"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView36"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView35"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView34"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView33"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView30"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView29"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView28"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView15"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView14"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView11"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>
                </LinearLayout>
            </HorizontalScrollView>
        </RelativeLayout>

        <ImageView
            android:id="@+id/ImageView16"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/RelativeLayout02"
            android:src="@drawable/ic_launcher" >
        </ImageView>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/Root_Layout_Iconset_Three_ID"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/ImageView27"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:src="@drawable/ic_launcher" >
        </ImageView>

        <RelativeLayout
            android:id="@+id/RelativeLayout04"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/ImageView27"
            android:layout_margin="5dip" >

            <HorizontalScrollView
                android:id="@+id/HorizontalScrollView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:scrollbars="none" >

                <LinearLayout
                    android:id="@+id/LinearLayout02"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <ImageView
                        android:id="@+id/ImageView42"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView41"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView13"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView09"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView08"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView10"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>

                    <ImageView
                        android:id="@+id/ImageView18"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/ic_launcher" >
                    </ImageView>
                </LinearLayout>
            </HorizontalScrollView>
        </RelativeLayout>

        <ImageView
            android:id="@+id/ImageView26"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/RelativeLayout04"
            android:src="@drawable/ic_launcher" >
        </ImageView>
    </RelativeLayout>
</LinearLayout>

Regards,
Hikmat Khan

  • 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-27T12:08:04+00:00Added an answer on May 27, 2026 at 12:08 pm

    Yes you can you have to inflate the UI of xml using LayoutInflater and then you can get the UI elements from xml. Having access to UI objects you can add extra layer of UI elements on to them and finally set them to setContentView()

    LayoutInflater mInflater = LayoutInflater.from(this);  
    View contentView = mInflater.inflate(R.layout.main, null); 
    LinearLayout root = (LinearLayout) contentView.findViewById(R.id.root);// mContainerIconExtension in your case
    root.addView(new TextView(this));
    setContentView(root);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML that I want to load to objects, manipulate those objects
I have situation where a user can manipulate a large set of data (presented
I have an interactive web application powered by jQuery where users can manipulate visual
Is there an easy way to manipulate PNGs in Java? I know I can
I know that I can use DOMDocument and DOMXPath to manipulate XML files. But,
instead of writing code in the standard way: $.get('test.xml',function(){ //manipulate the code here })
I wonder how I can manipulate the DOM tree using PHP? I have seen
Is it possible to use PHP's SimpleXML functions to create an XML object from
I have an issue of using PHP 5's XSLTProcessor to manipulate the following XML
Javascript can manipulate the document the browser is displaying, so the following: <script> document.write(<table><tr><td>Hola</td><td>Adios</td></tr></table>);

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.