What is the difference between xml based and Java based user interface?

♠ Posted by ANDROID THIRST in at 03:25
Have you ever find trouble to differentiate between android based and java based layout creation.
In this article, I am going to give you a brief demonstration about how to differentiate between these two way.
The basic building block of Android UI is the layout. A layout defines the visual structure for a user interface . You can arrange layout in two different ways .

1. Declaring UI element in XML :-  This is most preferable method use to create the user interface in android. We can use this method  when we want to create a simple static user interface in our android application. We used this method when the layout does not change . Suppose you are going to create UI for the login screen , for creating this we used XML because the layout does not change the login screen in future.


2. Declaring UI element in Java:- In terms of strengths of Java coding approach to layout creation ,
perhaps the most significant advantage that java has over XML resource files comes into play when dealing with the dynamic user interface. XML resource files are inherently  most useful when defining static layouts, In other words, the layouts that are unlikely to change significantly from one invocation of an activity to next. On the other hand, Java code is ideal for creation user interface dynamically at run-time.This is particularly important in situations where  the user interface may appear differently each time the activity execute subject to an external factor. 

0 comments:

Post a Comment