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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:02:14+00:00 2026-06-15T23:02:14+00:00

Android SDK offers to developers to write layouts in xml files or directly in

  • 0

Android SDK offers to developers to write layouts in xml files or directly in java code. I have read about it and everyone says that xml are easier to maintain and simplyer to write, but they are static. Otherwise java layout are dynamic, but no one comments performance issues. The only one thing which I found about performance was nesting layout have negative impact of performance. Instead of writing nested layout it’s better to make custom one. So far so good ;).

What about layout design? xml or java code? How are xml files parsed my android, at runtime or compile time? Even if they are parsed at compile time, they should be used in runtime. So which will be faster to declare RelativeLayout in xml or to declare it in onCreate method?

  • 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-15T23:02:16+00:00Added an answer on June 15, 2026 at 11:02 pm

    A layout defines the visual structure for a user interface, such as the UI for an activity or app widget. You can declare a layout in two ways:

    • Declare UI elements in XML. Android provides a straightforward XML
      vocabulary that corresponds to the View classes and subclasses, such
      as those for widgets and layouts.

    • Instantiate layout elements at runtime. Your application can create
      View and ViewGroup objects (and manipulate their properties)
      programmatically.

    The Android framework gives you the flexibility to use either or both of these methods for declaring and managing your application’s UI. For example, you could declare your application’s default layouts in XML, including the screen elements that will appear in them and their properties. You could then add code in your application that would modify the state of the screen objects, including those declared in XML, at run time.

    The ADT Plugin for Eclipse offers a layout preview of your XML — with the XML file opened, select the Layout tab.

    You should also try the Hierarchy Viewer tool, for debugging layouts — it reveals layout property values, draws wireframes with padding/margin indicators, and full rendered views while you debug on the emulator or device.

    The layoutopt tool lets you quickly analyze your layouts and hierarchies for inefficiencies or other problems.

    The advantage to declaring your UI in XML is that it enables you to better separate the presentation of your application from the code
    that controls its behavior. Your UI descriptions are external to your
    application code, which means that you can modify or adapt it without
    having to modify your source code and recompile. For example, you can
    create XML layouts for different screen orientations, different device
    screen sizes, and different languages. Additionally, declaring the
    layout in XML makes it easier to visualize the structure of your UI,
    so it’s easier to debug problems.

    When you compile your application, each XML layout file is compiled into a View resource. You should load the layout resource from your application code, in your Activity.onCreate() callback implementation. Do so by calling setContentView(), passing it the reference to your layout resource in the form of:

    I think its too much just visit this link http://developer.android.com/guide/topics/ui/declaring-layout.html and get more information..

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

Sidebar

Related Questions

The Android SDK offers the standard menu icons via android.R.drawable.X . However, some standard
I have installed Android SDK and packages. Since I had an error when opening
I installed: Android SDK Cygwin Ant Android NDK Java Eclipse and Download Moai SDK
I have installed android sdk under Windows 7. But when I run it, I
After downloading/installing Android SDK, it put the files/folders here: C:\Program Files (x86)\Android\android-sdk if I
I have android sdk 2.1 and it cannot resolve android.media.MediaFile package. Why is it
Sometimes Android SDK compiling Project will generate an empty layout XML named main.out.xml ,
the Android SDK actually offers a nice interface to access the sensors. But e.g.
Android SDK Manager complains WARNING: Java not found in your path. Instead of using
Android SDK seems to have a good wrapper interfaces in package android.database.sqlite, can this

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.