You are on page 1of 26

Android Developing

(Building Layouts 1)
by/
by/ Abdullah
Abdullah Alialdin
Alialdin

One Million Arab Coders program


What is Android?

• Android is an operating system and


programming platform developed by
Google for smartphones and other
mobile devices (such as tablets).
EXTRA
Developing Apps
• Use the Android software
development kit (SDK) to develop
apps that take advantage of the
Android operating system and UI.
• To develop apps using the SDK, use
the (JAVA) for developing the app
and (XML) files for describing data
resources.
SDK EXTRA

documentation
debugger

The SDK includes a


sample
libraries  comprehensive set of code 
development tools

emulator tutorials
Android Studio EXTRA

• To help you develop your


apps efficiently, Google
offers a full Java Integrated
Development Environment
(IDE) called Android Studio.
• Downloads:
JDK: http://
www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.
html
Android Studio: https://developer.android.com/studio/
Setup Android Studio on Windows EXTRA

• Download Java JDK


• You'll need the Java JDK, Either the 64 or 32 bit Windows download, depending
on your system.
• Launch the .exe file you just downloaded.
• Make sure you keep all the default settings for stuff you are installing so
Android Studio knows where to find it. 
• Download Android Studio
• Launch the .exe file you just downloaded.
• Follow the setup wizard to install Android Studio and any necessary SDK tools.
• On some Windows systems, the launcher script does not find where Java is
installed. If you encounter this problem, you need to set an environment
variable indicating the correct location.
Views

• The UI consists of a hierarchy of


objects called views — every
element of the screen is a view.
• A View is a rectangular area on
the screen. For example,
a TextView displays text and
an ImageView displays an
image.
Program code

• Program code is the set of


instructions forming
a computer program which
is executed by a computer.
XML

• Extensible Markup Language (XML)


is a markup language that
defines a set of rules for
encoding documents in
a format that is both human-
readable and machine-
readable.
Case Types
• Capitalization Writing the first letter of a word in uppercase, and the rest of
the letters in lowercase.
• lowercase All letters in all words are lowercase.
• ALL CAPS All letters in every word are capitalized.
• CamelCase Words are written without spaces, and the first letter of each
word is capitalized.
• pascalCase A variation of Camel Case in which the fist letter of the word is
lowercase, e.g. iPhone, iPad, etc.
• SNAKE_CASE Punctuation is removed and spaces are replaced by a single
underscore. Can be done with either upper or lowercase.
XML Element

• An XML element is everything from (including) the


element's start tag to (including) the element's end tag.
• Every element should contain:
1. Start tag
2. Type of view
3. List of attributes
4. End Tag
Closing Tag

• All XML Elements Must Have a Closing


Tag.
• In XML, it is illegal to omit the closing tag.
• An XML element can be closed in two
Self-closing

possible ways
• Self-closing tag children
• Non-empty closing tag parent
Non-empty
Attributes

• Specifications that defines a property of an element, like:

Width Height Color …etc.

• Each attribute consists of a name and a value.


• We write the name of the attribute on the left, the value on
the right, and join them with an equal sign. The value is always
enclosed in double quotes.
 Density-independent pixel (dp)

• The screen of an Android device is made of rows and columns


of glowing dots called pixels.
• If we specify the size of views in pixel values, then views would
appear very small on the higher density devices.
• To achieve a consistent physical size of Views, across devices of
different screen densities, we use a unit of measure called a dp.
• Android devices will automatically handle the conversion from
dp to pixel values.
Getting past errors

• Read the error message

• Compare the working code.

• Undo

• Ask for help


Hardcoding

• A computer is a machine that follows a list of


instructions called a program. An Android device is a
computer and an app is a program.
• One way to get information into an app is to write it
in the instructions of the app.
• This is called hardcoding the information into the
app.
Hardcoding
• Simply it’s a fixed value.
• We would have to remember to rewrite this value if we ever
changed the width of the TextView’s parent.
• This is one reason why we avoid writing hardcoded values.
wrap_content vs match_parent
• Every View is contained in a larger View called
its parent View, and we imagine that the parent of
the largest View of all is the glass rectangle of the
screen.
• We could write an instruction that would tell the
TextView to get its width or height automatically
from its parent by the value match_parent.
• Alternatively, we can specify it as the special
value wrap_content to shrink-wrap the View around
its content.
wrap_content vs match_parent
The width of the text
view match the parent
width (match_parent)

The height of
the text view is
the same as the
text height
(wrap_content)
Scale-independent pixel (sp)
• This is like the dp unit, but it is also
scaled by the user's font size
preference. It is recommended you
use this unit when specifying font
sizes, so they will be adjusted for
both the screen density and user's
preference.
EXTRA
Understanding Density Independence In Android:
Hexadecimal Color (Hex Color)

• A color is created by mixing together


red, green, and blue, in that order.
• Write a hash sign (#) and then
specify the amount of each
component with a pair of
“hexadecimal digits”.
• 00 is the minimum amount, FF is the
maximum, and 80 is halfway.
ImageView

• To add Image to Android Studio:


1. Right click on res, new Image Asset
2. On Asset type choose Image
3. On Path choose your image path
4. Next->Finish
• Or you can Copy your image and paste
to drawable folder.
ImageView

• android:src gives the location where the image is stored, use the exact
name of the image without the format (@drawable/Image name).
• android:scaleType Controls how the image should be resized or moved
cent cent
to match the size of this ImageView.
cen
erCr erIn
Documentation

• Is information about devices and apps. It is written in a


human language such as English, and is read by a human
being.
• You can use Android developers documentation to solve
any problem you may face or to know everything about
your code and you can see Documentation about how to
write apps.
• https://developer.android.com/
Resources

• https://developer.android.com/
• https://developers.google.com/android/for-all/vocab-words/?
utm_source=udacity&utm_medium=course&utm_campaign=android_basi
cs
• https://google-developer-training.gitbooks.io/android-developer-fundamen
tals-course-concepts/content/en
/
• https://google-developer-training.gitbooks.io/android-developer-fundamen
tals-course-practicals/content/en
/
• https://en.wikipedia.org/
• https://www.w3schools.com/xml/xml_syntax.asp

You might also like