What Is Layout Resource File?
This section describes a Layout Resource File, which is XML file that defines a view hierarchy of nested view groups and views to provide a user interface layout on the Android device screen.
What Is Layout Resource File?
A Layout Resource File is an XML file that defines a view hierarchy of nested view groups and views
to provide a user interface layout on the Android device screen.
Here is an example of Layout Resource File:
<?xml version="1.0" encoding="utf-8"?>
android:text="Hello World, HelloAndroid"
- The namespace, http://schemas.android.com/apk/res/android,
defines the XML schema of layout resource files.
- Each XML element in the layout resource file defines a view object for the layout.
- Each attribute of each XML element defines a property of the view object.
- This layout one has two view objects in the view hierarchy: a LinearLayout view object
and a TextView view object.
- The LinearLayout view object is used as the root view and a container of other view objects
- The TextView view object is used to display a text message on the screen to the user.
With the introduction of Layout Resource Files, Android developers now have 3 options to created
layout and view objects:
- "Layout Resource File only" - All UI layouts and views are defined in layout resource files only.
The advantage of using layout resource files is that layouts and views can be easily customized
without changing the Java source code.
- "Java Class Code only" - All UI layouts and views are created in Java class code only.
The advantage of using Java code is that layouts and views can be dynamically managed based on
the execution time situation.
- "Mixed of Layout Resource File and Java Class Code" - Major UI layouts and views are defined layout resource files
and minor ones are created in Java class code. This is probably the best option.
Last update: 2015.
Table of Contents
About This Book
Installing JDK 1.8 on Windows System
Installation of Android SDK R24 and Emulator
Installing Apache Ant 1.9 on Windows System
Developing First Android Application - HelloAndroid
Android Application Package (APK) Files
Android Debug Bridge (adb) Tool
Android File Systems
Android 4.0.3 File Systems
AboutAndroid - Application to Retrieve System Information
android.app.Activity Class and Activity Lifecycle
►View Objects and Layout Resource Files
android.view.View Class - Base of User Interface Components
View, ViewGroup, Layout, and Widget
►What Is Layout Resource File?
AndroidView v1.0 - Creating a Layout in Java Class
AndroidView v2.0 - Creating a Layout in Resource File
AndroidView v3.0 - Referencing Views in Resource Files
AndroidView v3.1 - Layouts with Vertical Orientation
AndroidView v3.2 - Layouts with Horizontal Orientation
AndroidView v4.0 - Inserting Views to Parent Layout
Using "adb logcat" Command for Debugging
Build Process and Package File Content
Building Your Own Web Browser
Android Command Line Shell
Samsung Galaxy Tab 3 Mini Tablet
USB Debugging Applications on Samsung Tablet
Android Tablet - LG-V905R
USB Debugging Applications on LG-V905R Tablet
Android Phone - LG-P925g
USB Debugging Applications on LG-P925g Phone
PDF Printing Version