Tuesday, December 30, 2014

Android project, first things first : project files structure

When creating a new android project, a lot of files are generated and appears in our source tree view. Let's a look at what's inside.


Note: The content of java folder will be ignored here.

"XML is your ally"

Hope you like it beacuse XML is used almost everywhere ! Here is a quick description of all of them:

Info file

Defines the Application's main properties : minWidth, minHeight, initialLayout...

Manifest file

There are a lot of similitudes between the manifest file and a C# Assembly. It contains all information about application rights, package name, managed Intents, main components of the application (Activity, Receivers, ...)...
This file will require modifications during development.

Layout file

Graphical definition of an Activity/AppWidget. Most of the time, you will use the graphical interface to edit your screens but a bit of knowledge on layout files can be useful.

Resource files

These files contains user-defined strings, images, style sheets, dimensions... that can be accessed with an id.

<style name="config_message_style">
        <item name="android:textColor">#ccffffff</item>
        <item name="android:textStyle">bold</item>
        <item name="android:layout_width">35dip</item>
        <item name="android:singleLine">false</item>
    </style>

Referenced in a layout file like this:

<Button
        ...
        android:textAppearance="@style/config_message_style"
        ... />

All of those files are related to each other :


Why several folders with "same" names ?

The drawable folders contain images only with different resolutions (densities) in order to have a good rendering on all kind of devices (tablets, mobile phones, ...).

drawable - hdpi: ~240dpi
drawable - mdpi: ~160dpi
drawable - nodpi: ~160dpi (?)
drawable - xhdpi:~320dpi
drawable - xxhdpi:~480dpi

value-vXX indicates the values that should be used for Android API XX and higher.

Cem SOYDING

Author & Editor

Senior software engineer with 12 years of experience in both embedded systems and C# .NET

1 comments:

Note: Only a member of this blog may post a comment.

 
biz.