Layout:
A layout defines the visual structure for a user interface, such
as the UI for an activity or app widget.
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.
Android Activity doesn’t contain anything of its own. It loads a
layout i.e declared in /res/layout folder
in the project directory.
Layouts are important to your Android
applications, which is why Layouts have their very own
layout folder in the standard project resource folder architecture
for Android.
Initially android project directory has a activity_main.xml file
which defines the elements of the activity. Every class when act as an activity
must extends Activity class and override onCreate() method.
This onCreate() method to push it onto your screen on the startup
of your application activity.
Lets take a look to the activity_main.xml file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/smalltextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/mediumtextView"
android:layout_below="@+id/mediumtextView"
android:text="Small
Text"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
</RelativeLayout>
Lets have a look to the code (How to Load the xml layout):
public
class MainActivity extends
Activity {
@Override
public
void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
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.
There are various types of Layouts few of them are:
·
Linear Layout
·
Relative Layout
·
Table Layout
·
Grid View
·
Tab Layout
·
List View
Reach us At: - 0120-4029000 / 24 / 25 / 27 / 29 Mbl: 9953584548
Write us at: - Smruti@apextgi.com and pratap@apextgi.com
Ways to clean houses in Riyadh in record time*Ways of moving furniture in Riyadh*A steam cleaning company in Jeddah*An insect control company in Riyadh*Landscaping in Riyadh*Landscaping Company in Riyadh*Pest Control in Riyadh*Transportation of furniture in Medina
ReplyDelete
ReplyDeleteThank your valuable content.we are very thankful to you.one of the recommended blog.which is very useful to new learners and professionals.content is very useful for hadoop learners
Best ASP.NET MVC Online Training Institute
Best Spring Online Training Institute
Best Devops Online Training Institute
Best Datascience Online Training Institute
Best Advanced java Online Training Institute
Best C-language Online Training Institute
Best Hadoop Online Training Institute
Best UI-Technologies Online Training Institute