Search code examples
androidandroid-framelayout

better approach for FrameLayout in android?


I'm using frameLayout in my project.. but I totally confused in android developement about that if I use xml file for static approach whereas on other side I'm using java code for run time behaviour for frameLayout(or any android feature) which approach is good for my project as user-experience point of view.. please provide only your straight forward sight of view with reason.. thanx in advance.


Solution

  • it's something similiar to earliar asked question.

    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 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.

    please do visit for more refference to http://developer.android.com/guide/topics/ui/declaring-layout.html